问题
I want to asynchronously download multiple glacier files using thread pool. My current approach uses High Level API for Glacier download, but every thread waits at download method until the download job is complete. Below is the code where all the treads are waiting
ArchiveTransferManager manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USEast1);
DownloadOptions options = new DownloadOptions();
manager.Download(vaultName, archiveId, downloadFilePath, options);
Can somebody please suggest me how to download archive asynchronously, so that my thread should come back after getting the job id and some event should get raised on download completion.
Regards, Haseena
回答1:
If Amazon doesn't offer an asynchronous API, you'll need to implement one yourself. You already have a thread for each download, just have your download thread notify your main thread when the download is done.
TPL can help you do that automatically - create a Task that downloads a file, and await
on it.
来源:https://stackoverflow.com/questions/22451833/asynchronous-amazon-glacier-download