Ask a questionAsk a question
 

QuestionManaged Threading Best Practices Documentation

  • Monday, November 02, 2009 7:57 PMRichDef Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    On the Managed Threading Best Practices page (http://msdn.microsoft.com/en-us/library/1c9txz50.aspx) there is a guidelines section and one guideline states: "Don't control the execution of worker threads from your main program (using events, for example). Instead, design your program so that worker threads are responsible for waiting until work is available, executing it, and notifying other parts of your program when finished."

    However, isn't the pattern used by the BackgroundWorker component (which I find to be very useful) based upon event notifications and therefore violates this principle?

    Is there something wrong with creating a producer/consumer queue system based upon the background worker class and its prewired events? I created something like using the backgroundworker class as the worker threads which seems to work just fine, but I'm concerened about hidden threadding problems that may not be immediately apparent.

    Thanks.