Sometimes, we need to create multiple threads. Before we can continue, however, we need to wait for these threads to complete doing whatever they need to do. For this, the use of tasks is best suited.
Creating multiple threads
Getting ready
Make sure that you add the using System.Threading.Tasks; statement to the top of your Recipes class.
How to do it...
- Create a new method called MultipleThreadWait() in your Demo class. Then, create a second method called RunThread() with the private modifier that takes an integer of seconds to make the thread sleep. This will simulate the process of doing some work for a variable...