-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
?