Forked from pageaffairs/gist:0ce4a2adb0cce160e09d65544dfeb3b4
Created
February 4, 2021 07:49
-
-
Save SitePointEditors/5d93de246850a964898fb5ca5fa7dfc1 to your computer and use it in GitHub Desktop.
ASP.NET application snippet: 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ResultType DoWork() | |
{ | |
ResultType retVal; | |
try { | |
var apiResult = CallAnAPIAsync().Result; | |
var fileName = CreateFileName(); | |
WriteToAFileAsync(fileName, apiResult).Wait(); | |
retVal = StartAsyncOperation(fileName).GetAwaiter().GetResult(); | |
} catch (AggregateException aex) { | |
HandleError(aex); | |
retVal = null | |
} | |
return retVal; | |
} | |
private async Task<APIResult> CallAnAPIAsync() {...} | |
private async Task WriteToAFileAsync() {...} | |
private Task<ResultType> StartAsyncOperation(string fileName) {...} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment