Asynchronous download of an Azure blob to string with .NET 4.5 async, await

前端 未结 3 1922
挽巷
挽巷 2021-02-05 19:27

I\'m trying to implement a fully asynchronous blob download with .NET 4.5 async & await.

Let\'s assume the entire blob can fit in memory at once, an

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 20:03

    1. Correct, they don't need to be async if they're not going to be long operations, which they shouldnt' be.

    2. Probably not, although I'm not familiar with this particular implementation. I would hope that since you're waiting for the stream to end before this point there should be no network work, and thus no expensive operations, to perform at this point. You should just be pulling data from a buffer, and it should be fast. This is easy enough to test, however. You can use something like Fiddler to see if there is network communication going on during that call, you can just time the method to see if it's taking long enough to appear that network IO is going on, or you could look through the docs of this specific stream implementation. Or you could just use the async method to be safe, which I would suggest, rather than risking being mistaken. I would be rather surprised to find that this needed to be async though.

    3. See #2.

提交回复
热议问题