コード例 #1
0
        private void DownloadFileAsyncBegin(string ticket, string fileId, string filePath)
        {
            _taskAsyncStarted = true;

            var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            var task          = Task <bool> .Factory.StartNew(() => DokuFlexService.Download(ticket, fileId, filePath));

            task.ContinueWith(t => DownloadFileAsyncEnd(t.Result), taskScheduler);
            task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception),
                              new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted,
                              taskScheduler);
        }