Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SitePointEditors/1519febd8c011a96d6dc23c9f4f53984 to your computer and use it in GitHub Desktop.
Save SitePointEditors/1519febd8c011a96d6dc23c9f4f53984 to your computer and use it in GitHub Desktop.
ASP.NET application snippet: 3
public async Task<ResultType> DoWorkAsync()
{
ResultType retVal;
try {
Task<APIResult> apiResultTask = CallAnAPIAsync();
var fileName = CreateFileName();
var apiResult = await apiResultTask;
await WriteToAFileAsync(fileName, apiResult);
retVal = await StartAsyncOperation(fileName);
} catch (RealException rex) {
HandleError(rex);
retVal = null
}
return retVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment