Hello,
I'm creating a new dialog box running with its own thread.
In the constructor of the dialog box, some UI components will be allocated, which are hosted under a canvas.
System.Threading.Thread thread = new System.Threading.Thread (() >
{
Dlg dlg = new Dlg ();
dlgVideo.Show ();
System.Windows.Threading.Dispatcher.Run ();
});
thread.SetApartmentState (System.Threading.ApartmentState.STA);
thread.Start ();
Then I try to modify some UI components.
dlg.Dispatcher.Invoke (new System.Action (() =>
{
dlg.DoSomeUIStuff ();
}));
The problem I have, is some cases, the call to dlg.Dispatcher.Invoke hangs for 15 to 20 seconds.
This really depends on the machine where I run the code. Sometimes, it doesn't hang, sometimes it does.
If I replace Invoke by BeginInvoke, then it won't hang anymore, but the command dlg.DoSomeUIStuff (); will be executed 15 to 20 seconds later.
Any clue?
What I have tried:
I try to replace Invoke by BeginInvoke, but it didn't solve the problem.