I am just starting to learn how Task works, and get one interesting case. I have HttpTaskAsyncHandler but I can't get acccess to HttpContext if my code inside ProcessRequestAsync calls to some Task
public class MyAsyncHandler : HttpTaskAsyncHandler, IReadOnlySessionState
{
public override async Task ProcessRequestAsync(HttpContext context)
{
//can use HttpContext here
await MyJob("data");
//can use HttpContext here
}
public async Task MyJob(string data)
{
var func = Task.Factory.StartNew(() => Process(data));
await func;
}
public string Process(string context)
{
**//can't use HttpContext here**
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
}
}
is it possible to fix ? I understand that Process method would be call in other tread but anyway. Thanks/