a) THREAD A: The method for the starting of the parallel task instantiates a new System.Threading.CancellationTokenSource Object
b) THREAD A: This CancellationTokenSource is given to the parallel task
c) THREAD B: The underlying method of the parallel task includes the type of CancellationTokenSource in its signature to take it over.
If a "cancel" button was pushed in THREAD A, then CancellationTokens method Cancel must be raised. This is done like this:
CancellationTokenSource.Token.Cancel();
The routine inside THREAD B (expecting while...wend loop for instance) is checking the CancellationTokenSource.Token.IsCancellationRequested = true
state and aborts its work in this case.
done!
based information : http://msdn.microsoft.com/de-de/library/dd997364%28v=vs.110%29.aspx
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
Sonntag, 30. November 2014
Samstag, 8. Februar 2014
shorter term of exception handling with the help of the Ternary operator
For example:
or
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
catch (System.ServiceModel.FaultException<AnyContract.ValidationError> ex)
{
Console.WriteLine(ex.Detail != null ? ex.Detail.Message : ex.InnerException != null ? ex.InnerException.Message : ex.Message);
}
or
catch (Exception ex)
{
Console.WriteLine(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
}
Benefit from the best Windows Desktop app in the world and use Strokey.Net!
Abonnieren
Posts (Atom)