Reputation: 16545
I have a method which is called on a different thread than UI thread.
When this method is called the control is gone , I mean nothing happens.
The code is like below:
private void MainForm_NewMeasurementState(Measurement measurement)
{
try
{
if (InvokeRequired)
{
// we were called on a worker thread
// marshall the call to the user interface thread
this.Invoke(new Action<Measurement>(MainForm_NewMeasurementState), new object[] { measurement });
return;
}
// some other code
}
The control comes in the if
statement but then I don't know what happens, the other code is never called.
Any help will be appreciated.
Upvotes: 0
Views: 58
Reputation: 837926
It could be that your main thread is blocked, perhaps because it is waiting for your code to complete (i.e. your code is deadlocked because two threads are waiting for each other).
Try to find out why the main UI thread is blocked, or else use BeginInvoke
instead of Invoke
.
Upvotes: 1