Easy Multithreaded Programming Using BackgroundWorker

Download this episode

Download Video

Description

Here's a quote from Chapter 6: Using Multiple Threads of the Smart Client Architecture and Design Guide:

"To maximize the responsiveness of your smart client applications, you need to carefully consider how and when to use multiple threads. Threads can significantly improve the usability and performance of your application, but they require very careful consideration when you determine how they will interact with the user interface."

.NET Framework 2.0 and the BackgroundWorker component to the rescue!  Marc Schweigert, Federal Developer Evangelist, shows you how easy it is to build a responsive multithreaded Smart Client application with Windows Forms 2.0 & the BackgroundWorker component.

Resources:

Federal Developer Blog:
http://blogs.msdn.com/federaldev/

BackgroundWorker Component Overview:
http://msdn2.microsoft.com/en-us/library/8xs8549b.aspx

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      JohnAskew
      Succint, valuable, and well presented.

      Some may say that Channel 9 for them is all about "getting to know personalities at Microsoft". Well, I'll trade all of that for training.

      This content is what Channel 9 offers me, and I thank you for it.

      [6][A]
    • User profile image
      SlackmasterK
      Very informative. This solved exactly the problem I was having, as I had never created a multithreaded app.  I appreciate the verbosity you went into to describe in detail how to implement and return event functionality as well.  Thanks!
    • User profile image
      Soviut
      Handy stuff.

      Although I know it would be easy to do, it would have been nice had the progress bar been used to show database load progress as well.
    • User profile image
      keydet
      I know it's been a while since I did this screencast, but I have posted the code here.  I am glad this helped some folks.  Thanks for the feedback.

      -Marc
    • User profile image
      guercheLE
      What I found interesting is that in the following statement there is no break instruction and the background worker breaks it whatsoever.

      private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
          for (int i = 1; i <= 10; i++)
          {
              if (backgroundWorker1.CancellationPending)
              {
                  e.Cancel = true;
              }
              else
              {
                  backgroundWorker1.ReportProgress(i * 10);
                  Thread.Sleep(1000);
              }
          }
      }
    • User profile image
      tes
      Hi
      I noticed that this video is no longer working on this site.  Is there anyway you can get this video to be functional again?
      thanks

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.