I have a standard Command and Schedule Task items in Sitecore that is being executed based on interval. I am trying to track progress of this job in jobs.aspx or code but everytime code calls another api, Sitecore.Context.Job or whole Context is lost and Job in jobs.aspx is also finished immediately, even though process still runs and logs everything correctly. Code where context is lost:
[Service(typeof(MyService))]
public class MyService
{
public async Task<HttpResponseMessage> GetResponse(string env)
{
// ...Deleted unnecessary part
using (var httpClient = new HttpClient())
{
var request = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = new FormUrlEncodedContent(dict),
};
response = await httpClient.SendAsync(request).ConfigureAwait(false);
}//Context lost after SendAsync()
}
return response;
}
}
Is there a way to keep the job in Job Manager/Job Viewer or what would be the recommended approach here? Sitecore 10.0.1.