Offshore your .NET/SQL Development to Latin America! Languages: en-de-es
Multithreading with asynchronous Delegates and Backgroundworker
November 18, 2007Posted by on
Programming true Multithreading is a hard job.
Yet using Multithreading to just create responsive UIs is a lot easier.
The biggest problem for later reuse of any code is always programming UI-code with intermingled business logic.
This HV.Pattern creates the possibility to encapsulate business logic in a backgroundworker that is called from within an own independent class.
The big hit is (see following illustration), that B (here in the HV.Tools-Assembly) encapsulates an asynchronous C.
During runtime the C will run on its own thread, making A’s UI absolutely responsive.
This is no pseudo-background working as with the use of a timer-control or with calls to me.update or Application.DoEvents.
This is true preemptive multitasking. You can even input the thread priority, receive whole objects on Progress_Changed.
And all this without the hassles of fighting with semaphores, queues and mutexes.
OK, clearly, you can’t let your code be reentrant to its own Bgw_DoWork. But we are talking about single instance background working.
Class Library Skeleton for the above Wait Class:
HV.Tools Class Library
Waits on a separate thread and sends feedback on intervals.
The following tables list the members exposed by the Wait type.
Not all Args implement getters and setters in this version.