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 - Assigning names to threads

You must identify each thread in the Threads window. This way, you will be able to easily find the problems in the encryption engine without getting confused.

Now, we are going to make some changes in the Thread class instances creating code, and to the BackgroundWorker in order to simplify the thread identification process during debugging:

  1. Stay in the project, SMSEncryption.
  2. Open the Click event in the button butRutRunInThread, and add the following code at the beginning:
    // Give the main thread a name
    Thread.CurrentThread.Name = "Main thread";
    
  3. Add the following line of code before starting each thread with the line prloThreadList[liThreadNumber].Start(liThreadNumber); in the for (liThreadNumber = 0; ...

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