O'Reilly logo

C# 2008 and 2005 Threaded Programming: Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - Understanding how to invoke delegates step-by-step

Now, we are going to execute the code in the AddToListBox method step-by-step, to have a better understanding of how delegates work in order to update the UI from worker threads:

  1. Stay in the project, MarsEncrypter.
  2. Open the code for the Windows Form Form1 (frmMarsEncrypter).
  3. Define a new breakpoint in the line if (libFilesEncrypted.InvokeRequired) in the AddToListBox method.
  4. Press F5 or select Debug | Start Debugging in the main menu. Make sure the Threads window is visible.
  5. Copy just one text file to be encrypted (around 10 megabytes in size to generate a processing impact) into the input folder while the application runs.
  6. After a few seconds, when the working thread finishes the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required