In trying MSDN\'s example on async/await, why I can\'t reach a break point after the await operator ?
private static void Main(string[] args)
{
AccessTheWebA
You call your asynchronous method from a Console application's Main method without waiting for the async method to finish. As a result, your process terminates before your task has a chance to complete.
Since you can't convert a Console application's Main to an asynchronous (async Task
) method, you'll have to block on the asynchronous method, by calling Wait
or .Result
:
private static void Main(string[] args)
{
AccessTheWebAsync().Wait();
}
or
private static void Main(string[] args)
{
var webTask=AccessTheWebAsync();
//... do other work until the resuls is actually needed
var pageSize=webTask.Result;
//... now use the returned page size
}