Creating
Task Class
This is a replacement for the ThreadPool.QueueUserWorkItem
For non generic task classes we call Task.Factory.StartNew and we pass in a delegate of the target method
System.Threading.Task myTask = new System.Threading.Task( () => System.Console.WriteLine("My new task") );
myTask.Start();
Factory.StartNew
Alternatively you could use this to create and start in one operation
System.Threading.Task.Factory.StartNew( () => System.Console.WriteLine("My new task") );
Task myTask = new Task( () => System.Console.WriteLine("hello") );
myTask.RunSynchronously();
Task Creation Options
LongRunning
PreferFairness
AttachedToParent
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext