using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FangYar.Common
{
///
/// Task线程统一控制帮助类
///
public class MyTaskControlHelper
{
///
/// 控制Task是否退出
///
private static CancellationTokenSource tokenSource;
///
/// 控制Task是否暂停
///
private static ManualResetEvent resetEvent = new ManualResetEvent(true);
///
/// 获取Task退出控制器
///
public static CancellationTokenSource TokenSource
{
get
{
if (tokenSource == null)
{
tokenSource = new CancellationTokenSource();
}
return tokenSource;
}
}
///
/// 获取Task暂停控制器
///
public static ManualResetEvent ResetEvent { get { return resetEvent; } }
}
}