Hi, Boni,
Having any UI (forms, controls or whatever) run on a thread other than the main foreground thread is generally Not A Good Thing To Do. It creates a host of headaches (race conditions, contentions, etc.) when trying to gain access to the various window resources available. It's far better to track down end eliminate whatever's causing the freeze-up.
That being said, there are certainly good uses for worker threads, and they can be leveraged to make your UI more responsive. I use them to take care of the number-crunching which doesn't impact the UI directly. So, for example, a user might click on a control and choose to do something performance intensive. What I do then it to disable the control after the click, spawn a thread and allow it to do the busy work, and when I'm informed that the thread has exited (via callback or message, whatever you like), I reenable the control and display whatever information is required. In the meantime, other controls can still be interacted with -- they're not frozen. I just need to be careful that nothing that those other controls do impacts any resources which that background thread requires. (Visual Studio itself works this way -- compilation, for example, occurs in a background thread so that you can still interact with the UI -- notably, "Cancel" among other things. The controls are still on the main thread; it's just the processing which is not.
The following link provides a general threading example:
http://msdn.microsoft.com/library/de...ingthreads.asp.
Hope this helps,
--Matt Gertz--*
VB Compiler Dev Lead
-----Original Message-----
From: Boni
Posted At: Tuesday, November 15, 2005 10:07 AM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: Multithreading trick needed
Subject: Multithreading trick needed
Dear all,
Is there some trick to put controls on a particular control but in other
thread.
Example:
A control is a part of bigger application and application thread freezes
somtimes. So a control freezes too. What I need is to spawn a thread and put
controls main thread in this thread.
Is it possible?
Thanks,
Boni