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 - Running the encryption in a new thread using the Thread class

As your freedom is dependent on this application, you want to minimize the risks! Therefore, you want to use the Thread class to have a very exhaustive control over the execution of the different threads. But, first, you want to make the encryption function run in just one thread. Later, you will align the threads with the number of cores.

Now, we are going to make some changes to the application, and we will encrypt the messages in a new independent thread created and configured using the Thread class:

  1. Open the project, SMSEncryption.
  2. Add a button control (butRunInThread). Set its Text property to Run in a thread.
  3. Add the following line of code at the beginning (as we ...

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