C# 5.0 in a Nutshell by Joseph Albahari & Ben Albahari
Author:Joseph Albahari & Ben Albahari [Joseph Albahari and Ben Albahari]
Language: eng
Format: epub
Tags: COMPUTERS / Programming Languages / C#
ISBN: 9781449334208
Publisher: O'Reilly Media
Published: 2012-03-21T16:00:00+00:00
Note
You can track a task’s execution status via its Status property.
Wait
Calling Wait on a task blocks until it completes and is the equivalent of calling Join on a thread:
Task task = Task.Run (() => { Thread.Sleep (2000); Console.WriteLine ("Foo"); }); Console.WriteLine (task.IsCompleted); // False task.Wait(); // Blocks until task is complete
Wait lets you optionally specify a timeout and a cancellation token to end the wait early (see Cancellation).
Long-running tasks
By default, the CLR runs tasks on pooled threads, which is ideal for short-running compute-bound work. For longer-running and blocking operations (such as our example above), you can prevent use of a pooled thread as follows:
Task task = Task.Factory.StartNew (() => ..., TaskCreationOptions.LongRunning);
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9921)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9799)
The Mikado Method by Ola Ellnestam Daniel Brolund(9782)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8305)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7786)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7768)
Grails in Action by Glen Smith Peter Ledbrook(7700)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7563)
Windows APT Warfare by Sheng-Hao Ma(6887)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6620)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6486)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6421)
Kotlin in Action by Dmitry Jemerov(5070)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4321)
Functional Programming in JavaScript by Mantyla Dan(4040)
Solidity Programming Essentials by Ritesh Modi(4032)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3822)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3765)
The Ultimate iOS Interview Playbook by Avi Tsadok(3739)
