Well, Are You!?
Here's an A-number-one reason for you, Joe: your application's perceived start-up time will kick the Major Ass!
Chances are even good that it will be real start-up time.
This is especially true when you have partitioned your UI "correctly" say, as plugins, and in your main form's start-up, you need to iterate all the loaded plugins and invoke the lifecycle start method, say ILifecycle.Start().
If we have a reasonable number of plugins, i.e. UI elements, the whole startup process bogs down in serial processing of everyone's startup. This typically invokes User Gak Syndrome, as your form appears, if at all, as a big, unrefreshed rectanglular glob on the screen.
Using the Windows Forms environment, this means that the ThreadPool, anonymous delegates, and Control.Invoke() are your newest, bestest buddies! No amount of work is too small to do anywhere but the UI thread!
I speak from experience, because I transformed my very own application to use increased background processing, and that biach snaps right up on the screen!
Before the transformation, start-up was becoming noticably slower, to the point of you could see each section refresh. Some other refresh cycles were also causing some noticable flashing, because some "inocuous" processing was trapped on the UI thread between BeginUpdate() and EndUpdate().
Since perception is everything, this approach gives your main form the opportunity it needs to get up on the screen and refreshed as fast as possible, without all of the initialization bogging it down.
So, to recap: in all of your startup and UI event handler responses:
- Take advantage of anonymous closures to capture all the context you need to do your processing and UI binding.
- Make a closure that will handle the UI binding. This gets used in
Control.Invoke().
- Make a closure that does the work, then calls
Control.Invoke() with the first closure. Use the UI element you are targeting in the call.
- Run the second closure on the
ThreadPool or dedicated Thread.
- Get off the UI thread! There's more work to do....