async void myButtonClicked (object sender, EventArgs e) { myProgressBar.Visibility = ViewStates.Visible; await myMethod(); myProgressBar.Visibility = ViewStates.Gone; }
async Task myMethod() { await Task.Run(() => { // Do long running stuff here }); }
if you are already calling something that uses await/async:
async Task myMethod() { var result = await someAsyncMethod(); processResult(result); // etc. etc. }