Abstract: Async Method and Exception

Abstract: Async Method and Exception


First, in the method of the internal program may have more than one await.

Second, as long as the front inside the await method comprising a program, there must be a method async modified.

Third, await expression is meant to apply to await the operator or Task Task prior to.

Fourth, await Catch block is not already present in the exception process or Finally block.

Fifth, when the program has been executed to the internal async method encounters await execution method will be suspended, and the first execution after the await an asynchronous method, asynchronous method to be finished after await the return Task or Task Then, a pause before re-release execution, pause and continue from the previous point.

Sixth, if a row in the previous program, the method returns to asynchronous or Task Task Specifies the first to give a temporary Task or Task And then the next line of the program, the use of expression The await await the operator to apply the front row or temporary Task Task , You must use the Try block to capture the Task or Task The exception message.

Seventh, in Task.WhenAll (), the only catch an exception and can not be predicted in advance where you can catch an exception.

Eighth, Task IsCanceled property set to True, or when IsFaulted property set to True, all will throw an exception, IsCanceled set to True representatives to cancel the job, IsFaulted set to True representatives of errors.

Reference data:

[1]try-catch (C# Reference)
http://msdn.microsoft.com/en-us/library/0yd65esw.aspx

Original: Big Box  Summary: Async Method and Exception


Guess you like

Origin www.cnblogs.com/chinatrump/p/11458326.html