Wait for an Asynchronous Method

The async and await pattern is a great way to ease asynchronous programming in .NET 4.5. When using await and the whole calling stack is not async (maybe it has no need to be), you will have to sometime forced to wait for a async method to finish before proceeding and not want to use await, because the current method is not async.

It is not very easy to find how to do this as most examples around async/await only. So how do you work with an async method without using await.

I am waiting a example using the Live SDK, which is full of async APIs like most libraries now a days

   1:   Dim LoginTask As Task(Of LiveLoginResult) = _AuthContext.LoginAsync(scope)
   2:   LoginTask.Wait(100)

All async methods return a Task or Task<> type. Instead of using await, you can use the above syntax to wait for the async method to finish. The parameter to the Wait call is the timeout value. If that is not used, then the application will wait indefinitely for the task to end.