How to synchronously call async method from quartz schedule job
<p>I am trying to call a webapi method from my quartz.net schedule job. I am not sure whether the way I am doing is right? Can anyone help if this is the right way or is there any better approach available?</p>

<p>MethodRepository.cs</p>

<pre><code>public async Task&lt;IEnumerable&lt;ResultClass&gt;&gt; GetResult(string queryCriteria)
{
    return await _httpClient.Get(queryCriteria);
}
</code></pre>

<p>Quartz job:</p>

<pre><code>public async void Execute(IJobExecutionContext context)
{
    var results= await _repo.GetResult();
}
</code></pre>

<p>generic Httpclient :</p>

<pre><code>public async Task&lt;IEnumerable&lt;T&gt;&gt; Get(string queryCriteria)
{
    _addressSuffix = _addressSuffix + queryCriteria;
    var responseMessage = await _httpClient.GetAsync(_addressSuffix);
    responseMessage.EnsureSuccessStatusCode();
    return await responseMessage.Content.ReadAsAsync&lt;IEnumerable&lt;T&gt;&gt;();
}
</code></pre>

<p>But the quartz documentation says I can't use async method in a quartz job. How can one the Web API method then?</p>

<p>Can I change the quartz job execute method as:</p>

<pre><code>public void Execute(IJobExecutionContext context)
{
    var result = _repo.GetResult().Result;
}
</code></pre>