April 2018
Intermediate to advanced
300 pages
7h 41m
English
In .NET Core, the threading API is the same as that used in the full .NET Framework version. A new thread can be created by creating a Thread class object and passing the ThreadStart or ParameterizedThreadStart delegate as a parameter. ThreadStart and ParameterizedThreadStart wrap a method that is invoked when the new thread is started. ParameterizedThreadStart is used for method containing parameters.
Here is a basic example that runs the ExecuteLongRunningOperation method on a separate thread:
static void Main(string[] args) { new Thread(new ThreadStart(ExecuteLongRunningOperation)).Start(); } static void ExecuteLongRunningOperation() { Thread.Sleep(100000); Console.WriteLine("Operation completed successfully"); ...Read now
Unlock full access