I have a stack of calls to a web api that need to be called asynchronously. I have never used the aysnc.
I have created a simple test console program, along the lines of :
class Program
{
static void Main(string[] args)
{
ClassOne xx = new ClassOne();
var v1 = xx.DummyTask();
}
}
With the class defined as :
namespace GHTest.classes
{
public class ClassOne
{
GitHubClient client;
public ClassOne()
{
client = new GitHubClient(new ProductHeaderValue("OMHSite"));
}
public async Task<string> DummyTask()
{
Task<Repository> task = client.Repository.Get("openEHR", "CKM-mirror");
task.Wait();
var myResult = task.Result;
return myResult.FullName;
}
}
}
Visual Studio states I should use the "await" operator as currently this code will run synchronously. Where does the await operator go?
Furthermore if the following statement throws an exception, how do I catch that in the task
client.Repository.Get("openEHR", "CKM-mirror");