// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#if NET_4_0 || BOOTSTRAP_NET_4_0
+#if NET_4_0
using System;
using System.Collections.Generic;
public sealed class CancellationTokenSource : IDisposable
{
- volatile bool canceled;
- volatile bool processed;
+ bool canceled;
+ bool processed;
int currId = int.MinValue;
}
// If parameter is true we throw exception as soon as they appear otherwise we aggregate them
- public void Cancel (bool throwOnFirst)
+ public void Cancel (bool throwOnFirstException)
{
canceled = true;
handle.Set ();
List<Exception> exceptions = null;
- if (!throwOnFirst)
+ if (!throwOnFirstException)
exceptions = new List<Exception> ();
lock (callbacks) {
foreach (KeyValuePair<CancellationTokenRegistration, Action> item in callbacks) {
- if (throwOnFirst) {
+ if (throwOnFirstException) {
item.Value ();
} else {
try {
}
}
+ Thread.MemoryBarrier ();
processed = true;
if (exceptions != null && exceptions.Count > 0)
sw.SpinOnce ();
}
-
- internal void ThrowIfCancellationRequested ()
- {
- if (canceled)
- throw new OperationCanceledException (CreateToken ());
- }
-
+
CancellationTokenRegistration GetTokenReg ()
{
CancellationTokenRegistration registration