Exception in C#

Posted by user1803513 on Stack Overflow See other posts from Stack Overflow or by user1803513
Published on 2012-11-21T10:57:32Z Indexed on 2012/11/21 10:59 UTC
Read the original article Hit count: 148

Filed under:
|
|

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;

© Stack Overflow or respective owner

Related posts about c#

Related posts about c#-4.0