summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Threading/CancellationToken.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Threading/CancellationToken.cs')
-rw-r--r--src/mscorlib/src/System/Threading/CancellationToken.cs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/mscorlib/src/System/Threading/CancellationToken.cs b/src/mscorlib/src/System/Threading/CancellationToken.cs
index 48a2344c31..5b78f20900 100644
--- a/src/mscorlib/src/System/Threading/CancellationToken.cs
+++ b/src/mscorlib/src/System/Threading/CancellationToken.cs
@@ -8,9 +8,9 @@
#pragma warning disable 0420 // turn off 'a reference to a volatile field will not be treated as volatile' during CAS.
using System;
-using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Permissions;
+using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime;
using System.Runtime.CompilerServices;
@@ -39,7 +39,6 @@ namespace System.Threading
/// </para>
/// </remarks>
[ComVisible(false)]
- [HostProtection(Synchronization = true, ExternalThreading = true)]
[DebuggerDisplay("IsCancellationRequested = {IsCancellationRequested}")]
public struct CancellationToken
{
@@ -167,7 +166,7 @@ namespace System.Threading
private static void ActionToActionObjShunt(object obj)
{
Action action = obj as Action;
- Contract.Assert(action != null, "Expected an Action here");
+ Debug.Assert(action != null, "Expected an Action here");
action();
}
@@ -192,7 +191,7 @@ namespace System.Threading
public CancellationTokenRegistration Register(Action callback)
{
if (callback == null)
- throw new ArgumentNullException("callback");
+ throw new ArgumentNullException(nameof(callback));
return Register(
s_ActionToActionObjShunt,
@@ -227,7 +226,7 @@ namespace System.Threading
public CancellationTokenRegistration Register(Action callback, bool useSynchronizationContext)
{
if (callback == null)
- throw new ArgumentNullException("callback");
+ throw new ArgumentNullException(nameof(callback));
return Register(
s_ActionToActionObjShunt,
@@ -260,7 +259,7 @@ namespace System.Threading
public CancellationTokenRegistration Register(Action<Object> callback, Object state)
{
if (callback == null)
- throw new ArgumentNullException("callback");
+ throw new ArgumentNullException(nameof(callback));
return Register(
callback,
@@ -318,14 +317,13 @@ namespace System.Threading
}
// the real work..
- [SecuritySafeCritical]
[MethodImpl(MethodImplOptions.NoInlining)]
private CancellationTokenRegistration Register(Action<Object> callback, Object state, bool useSynchronizationContext, bool useExecutionContext)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
if (callback == null)
- throw new ArgumentNullException("callback");
+ throw new ArgumentNullException(nameof(callback));
if (CanBeCanceled == false)
{