J
Julie
It looks to me like InvokeRequired() is returning an unexpected
result.
I have a multi-threaded app, and know it's a good idea to put all
functionality related to a Windows Forms control on the same thread.
I have a class which inherits from Form. When I construct an object of
this class, I print out the value for
Thread.CurrentThread.ManagedThreadId.
In all of the functions in my class, I have the same structure:
public delegate void functionNameCallback();
public void functionName()
{
if (this.InvokeRequired)
{
functionNameCallback e = new functionNameCallback(functionName);
this.Invoke(e, null);
}
else
{
// print value of Thread.CurrentThread.ManagedThreadId here
....
// do whatever work here
}
}
I can see that the thread that is calling the function is getting
"InvokeRequired" set to false; therefore, it is just doing the work
without invoking. The value for Thread.CurrentThread.ManagedThreadId
printed in the function does not match the value printed in the
constructor.
What's going on???
result.
I have a multi-threaded app, and know it's a good idea to put all
functionality related to a Windows Forms control on the same thread.
I have a class which inherits from Form. When I construct an object of
this class, I print out the value for
Thread.CurrentThread.ManagedThreadId.
In all of the functions in my class, I have the same structure:
public delegate void functionNameCallback();
public void functionName()
{
if (this.InvokeRequired)
{
functionNameCallback e = new functionNameCallback(functionName);
this.Invoke(e, null);
}
else
{
// print value of Thread.CurrentThread.ManagedThreadId here
....
// do whatever work here
}
}
I can see that the thread that is calling the function is getting
"InvokeRequired" set to false; therefore, it is just doing the work
without invoking. The value for Thread.CurrentThread.ManagedThreadId
printed in the function does not match the value printed in the
constructor.
What's going on???