- Open Visual Studio 2017.
- Now, open the solution from the previous recipe. Click File | Open | Open Project/Solution, or press Ctrl + Shift + O, and select the Chapter6.Threads solution.
- Press Ctrl + Shift + B for a quick build to check that everything is fine.
- Click on the Chapter6.Threads solution label. Click File | Add | New Project.
- In the Add New Project template dialog box, expand the Visual C# node in the left-hand pane.
- Select .NET Core and select Console App (.NET Core) in the right-hand pane:
- Now, in the Name: textbox, type Chapter6.Threads.ThreadsCore as the name of the project. The rest of the fields should be left as they are:
- Click OK.
- Now, the Solution Explorer (press Ctrl + Alt + L) should display like this:
- Right-click on the Dependencies label in the Chapter6.Threads.ThreadsCore.
- Select Add Reference.
- In the Reference Manager, click on the Projects label in the right-hand pane:
- Check the Chapter6.Threads.ThreadLib project in the left-hand pane.
- Click OK.
- Now, double-click on the Program.cs label in the Solution Explorer.
- Scroll up in the code window and add the following using directive:
using Chapter6.Threads.ThreadLib;
- Now, delete any existing code generated by Visual Studio in the Main() method and add the following code:
var threads = new ThreadGenerator();
var output = threads.StartThreads();
Console.WriteLine(output);
Console.ReadLine();
- Press F5 to execute the app.
- You should see output like this:
- Press Enter to exit.