Where do I handle asynchronous exceptions?

Posted by Jurily on Stack Overflow See other posts from Stack Overflow or by Jurily
Published on 2010-06-16T04:48:11Z Indexed on 2010/06/16 4:52 UTC
Read the original article Hit count: 242

Consider the following code:

class Foo {
    // boring parts omitted

    private TcpClient socket;

    public void Connect(){
        socket.BeginConnect(Host, Port, new AsyncCallback(cbConnect), quux);
    }

    private void cbConnect(IAsyncResult result){
            // blah
    }
}

If socket throws an exception after BeginConnect returns and before cbConnect gets called, where does it pop up? Is it even allowed to throw in the background?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET