Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (28 sloc) 0.724 kB
using System;
namespace PortableTPL.Cancellation
{
public class CancellationToken
{
Action _cancellationAction;
public bool IsCancellationRequested { get; private set; }
public void Register(Action action)
{
_cancellationAction = action;
}
public void ThrowIfCancellationRequested()
{
if (IsCancellationRequested)
{
throw new OperationCanceledException(this);
}
}
internal void Cancel()
{
IsCancellationRequested = true;
if (_cancellationAction != null)
{
_cancellationAction();
}
}
}
}
Jump to Line
Something went wrong with that request. Please try again.