-3
我一直在寻找的async
的解释 - 这说异步等待在功能上等同于任务延续是否为真?
async Task<int> IndexWordsFromAsync(string url)
{
string content = await httpClient.GetStringAsync(url);
int wordCount = AddContentToIndex(content);
return wordCount;
}
int AddContentToIndex(string content)
{
...
}
相当于
Task<int> task = IndexWordsFromAsync(url);
var currentContext = SynchronizationContext.Current;
task.ContinueWith(delegate
{
if(currentContext == null)
RestOfMethod();
else
currentContext.Post(delegate { RegstOfMethod(); }, null);
}, TaskScheduler.Current);
有人可以确认到什么程度这是真的await
?或者你可以将我链接到互联网上的某个地方,这种方式描述了async
- await
?