Develop an OData online, occasionally offline, or offline application.
C# and Visual Basic allow you to asynchronously program without the need of callbacks.
Asynchronous methods are easier to write:
-
async makes your method asynchronous
-
await makes the rest of your method a callback as this
example
illustrates:
private async void button1_Click(object sender, EventArgs e)
{
// Call the method that runs asynchronously.
string result = await WaitAsynchronouslyAsync();
result += await AnotherWaitAsynchronouslyAsync();
// Display the result.
textBox1.Text += result;
}
In C#:
- The async keyword in the method signature informs the
compiler that the method is asynchronous.
- When calling the asynchronous method, use the await
keyword.
- The compiler immediately returns control to the caller.
- When the asynchronous method completes, the compiler starts execution from where
it left off.
- Since the rest of the method runs in the main UI thread, you can update UI
controls from within the method itself.
NoteThe following image contains links to more information.