Side by side issues

This is something of a dying art, since Microsoft is doing their level best to pretend that .NET 1.0 doesn't exist any more-- but here are a few key utilities you'll need when running .NET 1.0 and 1.1 side by side.


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2004/08/side-by-side-issues.html

Two comments:

  1. It would seem to me to be less than perfect code to assume the application is running on the primary screen. Therefore, I suspect SystemInformation.WorkingArea is more appropriate to determine the screen dimensions.

  2. Why on earth (or heaven… or hell) do you say DoEvents is the call of the devil??? How else can I get a form to paint during program startup, instead of leaving a nasty white, half-painted frame while data is being read in? What’s wrong with yielding for one cycle?

regarding #2, Application.DoEvents() is something you really do want to avoid when possible. If your form is not painting right away because you are doing something intensive like reading a file, or hitting a DB or webservice, then you should run the intensive logic on a separate thread and leave the UI thread alone. If this is a simple “for yourself” kind of app, then no need to get fancy and Application.DoEvents() is fine. But for anything that is a professional app, you need to make proper use of UI and non-UI threads. In .NET 2.0 the easiest way to do this is using the BackgroundWorker component.

With that said, there are some special cases where Application.DoEvents() is OK to use. For me, I use it in my splash screen when an app is going through its various loading steps (so the progress bar will repaint). But other than that I avoid it and any web service/DB/file IO is done on background threads which notify the UI thread when they complete.