Traditionally working the way it is done with BackgroundWorker
Basically, this is a simple class that gives you the ability to execute a function in a work thread, and then is automatically called back into the user interface thread after this function completes. During the execution of the function, the user interface is unlocked and can display a progress message or process other user input (for example, cancellation).
The result is similar to your template, but a separate thread is created and destroyed (well, actually there is a union ...) for each task.
UI thread ---> Show splashscreen -------------------> Show window -------
| | return to UI |
| create background worker | |
-> Process user ------------ -> Perform query etc.
Good, based on your comment:
You can use such a template, this is a simple eventing event. Give the user interface access to your manager so that he can make a method call on it and register events when the task is completed ( this link shows two basic patterns for asynchronous operations in .NET). Inside the manager, you will need to keep a list of tasks that can be executed sequentially in one thread and ensure that events that are called to return the results to the user interface are correctly called so that they are executed in the main user interface thread (basically recreate the background work pattern )
I'm not sure what you hope to get by doing this, is there a reason why an application should be limited to two threads? Are you worried about the cost of creating background workers? Do you need some kind of query system? The diagram examples in your question do not seem to require the complexity of this type of template.
Martin Harris Aug 26 '09 at 10:04 2009-08-26 10:04
source share