Task. Run () 작업 수행

1) Task 자체 가 비동기 적 으로 실 행 된 것 (4.5 의 그런 종류) 이다.
2) 제어 수량 과 종료 라인 문 제 는 이 모델 을 고려 할 수 있다.
static async void RunAsync()
        {
            CancellationTokenSource ts = new CancellationTokenSource();
            CancellationToken c = ts.Token;
 
            await Task.Run(() => 
            {
                //        ……
 
            },c).ContinueWith
            ((t) => 
            {
                //      ……
            },c);
 
            c.Register(() =>
            {
                //   Task    ,             
            });
            //      
            ts.Cancel();
        }

좋은 웹페이지 즐겨찾기