|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Switching to the UI ThreadHi,
I'm customizing a COM app with .NET and my function is being called on a worker thread. I'd like to show a dialog on the UI thread, is there a way for me to find the UI thread and execute my code on it (new form...)? Thanks, Steve Hello, Steve!
S> Hi, S> I'm customizing a COM app with .NET and my function is being called on a S> worker thread. I'd like to show a dialog on the UI thread, is there a S> way for me to find the UI thread and execute my code on it (new S> form...)? If you have reference ( or know how to obtain it ) to the main form, then you can call .Invoke method in order to marshal the call to the UI thread. ( www.codeproject.com/csharp/winformthreading.asp ) If you have no UI thread, you can create it, with the same code as wizard in VS generates you, when creating WinForms project... Hi. Thanks for the reply.
I do have a reference to the main window but it's an MFC window, I have its hWnd. Show quote "Vadym Stetsyak" wrote: > Hello, Steve! > > S> Hi, > S> I'm customizing a COM app with .NET and my function is being called on a > S> worker thread. I'd like to show a dialog on the UI thread, is there a > S> way for me to find the UI thread and execute my code on it (new > S> form...)? > > If you have reference ( or know how to obtain it ) to the main form, then you can call .Invoke method in order to marshal the call to the UI thread. > ( www.codeproject.com/csharp/winformthreading.asp ) > > If you have no UI thread, you can create it, with the same code as wizard in VS generates you, when creating WinForms project... > -- > Regards, Vadym Stetsyak > www: http://vadmyst.blogspot |
|||||||||||||||||||||||