In one of my classes, I have got code:
private static void Notify(string url, string author, string mess)
{
Toast slice = new Toast(100000, url, author, mess) { Height = 90 };
slice.Show();
return;
}
public void Job()
{
Notify("http://google.com", "username", "hi all");
while (true)
{
if (Run() == false)
break;
}
/* .... */
}
Notify function is displays a small box with my text. it works well, but if it comes after a loop, then the program hangs. ie if after Notify("http://google.com", "username", "hi all"); add return;, program will not hang.
I tried to make this function in another thread, but then for some reason it does not work properly and displays a “white list”. What am I doing wrong and what you can do in this situation? Sorry for bad English.
From what’s been said in the comments, I may have a solution for you.
First, be sure you are calling
Job()from the main UI thread. For example, directly in a UI object Event Handler, or within a call to a UI object’sInvoke()method.Then I would change your code as follows:
Note that I remove the loop entirely, and I use
ShowDialog()to prevent further interaction with the program until theslicewindow is closed.I’ve also put
slicein ausing()block, because it should haveDispose()called when you are done with it.