annotate Implab/ICancellationToken.cs @ 243:b1e0ffdf3451 v3

working on promises
author cin
date Wed, 24 Jan 2018 19:24:10 +0300
parents 706fccb85524
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
1 using System;
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
2
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
3 namespace Implab {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
4 public interface ICancellationToken {
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
5 /// <summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
6 /// Indicates wherther the cancellation was requested.
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
7 /// </summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
8 bool IsCancellationRequested { get ; }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
9
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
10 /// <summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
11 /// The reason why the operation should be cancelled.
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
12 /// </summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
13 Exception CancellationReason { get ; }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
14
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
15 /// <summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
16 /// Accepts if requested.
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
17 /// </summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
18 /// <returns><c>true</c>, if if requested was accepted, <c>false</c> otherwise.</returns>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
19 bool CancelOperationIfRequested();
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
20
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
21 /// <summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
22 /// Sets the token to cancelled state.
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
23 /// </summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
24 /// <param name="reason">The reason why the operation was cancelled.</param>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
25 void CancelOperation(Exception reason);
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
26
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
27 /// <summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
28 /// Adds the listener for the cancellation request, is the cancellation was requested the <paramref name="handler"/>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
29 /// is executed immediatelly.
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
30 /// </summary>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
31 /// <param name="handler">The handler which will be executed if the cancel occurs.</param>
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
32 void CancellationRequested(Action<Exception> handler);
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
33
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
34 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
35 }
706fccb85524 RC: cancellation support for promises + tests
cin
parents:
diff changeset
36