TransferManager.UploadAsync停留在WaitingForActivation

时间:2018-06-06 10:05:50

标签: c# winforms azure

我试图使用Microsoft.Azure.Storage.DataMovement包从UI上传Blob文件到Azure,但一直遇到死锁,我需要等待上传完成才能删除文件。我按照DataMovement站点上的示例代码进行操作,但是当我发出task.Wait()时,它会阻止该线程,我不能在生活中解决如何在UI中执行此操作。

// Setup the number of the concurrent operations
TransferManager.Configurations.ParallelOperations = 64;

// Setup the transfer context and track the upoload progress
SingleTransferContext context = new SingleTransferContext();
context.ProgressHandler = new Progress<TransferStatus>((progress) =>
{
    if (progressHandler != null)
    {
      int percentUploaded = (int)(progress.BytesTransferred / new FileInfo(creationArgs.SnapshotFileName).Length);

      progressHandler.Report(percentUploaded);
    }
});

// Upload a local blob
var task = TransferManager.UploadAsync(
    sourcePath, destBlob, null, context, CancellationToken.None);
task.Wait();

0 个答案:

没有答案