简体   繁体   English

DownloadStringAsync的返回类型为void。 那我该如何等待呢?

[英]DownloadStringAsync has return type void. So how do I await it?

Looking at the documentation here https://msdn.microsoft.com/en-us/library/ms144202(v=vs.110).aspx , DownloadStringAsync has return type void , which means VS gives me an error 看着这里的文档https://msdn.microsoft.com/en-us/library/ms144202(v=vs.110).aspxDownloadStringAsync有返回类型void ,这意味着VS给我一个错误

Cannot await 'void' 无法等待'无效'

So how am I supposed to use that method? 那么我该如何使用这种方法呢?

使用支持async / await模式的DownloadStringTaskAsync

public Task<string> DownloadStringTaskAsync(Uri address)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 多播代表的返回类型必须为void。 为什么? - Multicast Delegates must have a return type of void. Why? 如何使用WebClients DownloadStringAsync避免冻结UI? - How do I use WebClients DownloadStringAsync to avoid freezing the UI? 如何对返回类型为Void的私有方法进行Assert阶段? - How to do the Assert phase of a private method whose return type is Void? 为什么我无法在具有 void 返回类型的异步 function 中捕获异常? - why I couldn't catch the exception in async function that has void return type? DownloadStringTaskAsync 和 DownloadStringAsync 如何设法不阻塞 UI 线程? - How do DownloadStringTaskAsync and DownloadStringAsync manage to not block the UI thread? 如何更改“OnInspectorGUI()”void 中的值,以便我可以在另一个脚本中获取它? - How do I change a value in "OnInspectorGUI()" void so that I can get it in another script? 如果表达式返回类型为空,如何获取null? - How to get null if expression return type is void? 如何用void返回类型对方法进行单元测试? - How to unit test a method with void return type? CodeDom如何创建具有void返回类型的方法? - CodeDom How to create a method with void return type? 如何编写同时包含字符串和双精度类型的方法? 应该是void还是返回类型方法? - How can i write a method that contains both string and double type? should it be a void or return type method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM