I need help in some problem. In MainWindow WPF i read status from device and 0 is normal work, 1 is other status. I want to open new window when i get status = 1 and close it when i get 0. I try do it with timer and showDialog. New window is created but status in MainWindow doesn't change until i close new window manualy. Any sugestion how to do it without timer? Maybe some sample.
Thanks in advance.
MainWindow - timer tick:
public void t1_Tick(Object Sender, EventArgs e)
{
HttpWebRequest request7 = WebRequest.Create("http://localhost:8080/datasnap/rest/TAutomatServerMethods/uCard") as HttpWebRequest;
using (HttpWebResponse response7 = request7.GetResponse() as HttpWebResponse)
{
StreamReader reader7 = new StreamReader(response7.GetResponseStream());
string json7 = reader7.ReadToEnd();
// MessageBox.Show(json);
JObject o7 = JObject.Parse(json7);
int status_int = Convert.ToInt32(o7["result"][0]);
if (status_int == 1)
{
uCard uc1 = new uCard();
uc1.ShowDialog();
}
}
Window1 - close window
public void t1_Tick(Object Sender, EventArgs e)
{
if (MainWindow.status_int == 0 )
{
this.Close();
}
}
ShowDialogwill block the executing thread until it is closed.