#if MONO
using System;
using System.Collections.Generic;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Threading
{
/// Signals to a that it should be canceled.
[__DynamicallyInvokable, ComVisible(false)]
[HostProtection(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
public class CancellationTokenSource : IDisposable
{
private static readonly CancellationTokenSource _staticSource_Set = new CancellationTokenSource(true);
private static readonly CancellationTokenSource _staticSource_NotCancelable = new CancellationTokenSource(false);
private static readonly int s_nLists = (PlatformHelper.ProcessorCount > 24) ? 24 : PlatformHelper.ProcessorCount;
private volatile ManualResetEvent m_kernelEvent;
private volatile SparselyPopulatedArray[] m_registeredCallbacksLists;
private volatile int m_state;
private volatile int m_threadIDExecutingCallbacks = -1;
private bool m_disposed;
private CancellationTokenRegistration[] m_linkingRegistrations;
private static readonly Action