Hi, Pug
After EndInvoke finished running - where are you? Because you do EndInvoke
from BeginInvoke delegate you are definitely in some thread - not the UI
one. To return to UI thread you should use form.BeginInvoke and form must
exist on UI thread.
I would suggest to trace threads using Console.WriteLine or Debug.Print -
you will see that you try to update ui form on non-ui thread. That's why you
have problem.
HTH
Alex
"Pug Fugly" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am unable to call the .Show() method on a form that I have passed
> through .BeginInvoke as the AsyncState parameter. I can get back the
> form correctly after the .EndInvoke is called in the callback, but the
> process still seems to be on a different thread even though the
> .EndInvoke finished running. I get "Controls created on one thread
> cannot be parented to a control on a different thread." Which I know
> is not allowed, but I thought once .EndInvoke is done running I should
> be back to the original thread. The form is a module variable so it
> is not a scope problem. The only way I can get the form to show is if
> I create a delegate for the .Show() and call that with .Invoke(). But
> after that, I cannot bind to it's datagrid because I get the same
> error as above. It seems like I never return back to the same thread,
> or the threads are never aborting. What am I missing here?
>
> Thanks,
> Slavisa
|