Exception in C#
- by user1803513
I am facing null pointer exception in below code as it is happening very rarely and I tried to debug to replicate the issue but no luck. Can anybody help me what can cause null point exception here.
private static void MyTaskCompletedCallback(IAsyncResult res)
{
var worker = (AsyncErrorDelegate)((AsyncResult)res).AsyncDelegate;
var async = (AsyncOperation)asyncResult.AsyncState;
worker.EndInvoke(res);
lock (IsAsyncOpOccuring)
{
IsBusy = false;
}
var completedArgs = new AsyncCompletedEventArgs(null, false, null);
async.PostOperationCompleted(e => OnTaskCompleted((AsyncCompletedEventArgs)e), completedArgs);
}
Null Pointer exception is reported at
var async = (AsyncOperation)asyncResult.AsyncState;