C# 线程

private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
    
//开始线程 Task.Factory.StartNew(()
=> { while (!cancellationTokenSource.IsCancellationRequested) { try { catch (Exception ex) { throw new Exception(ex.Message); } finally { } } }, cancellationTokenSource.Token);
//设置退出循环 cancellationTokenSource.Cancel();
posted @ 2019-12-17 15:40  游不动  阅读(172)  评论(0编辑  收藏  举报