M
Mark Hoffman
All,
My application spawns a worker process by calling BeginInvoke with an
asynchronous callback method. This callback method is responsible for
calling EndInvoke. No problems there; pretty much straight out of MSDN.
My question is what happens when my worker thread raises an exception? I can
easily catch the exception, but I've noticed that unless my async callback
runs and EndInvoke gets called, then the worker thread never gets returned
to the threadpool. (Which makes perfectly good sense.)
So, how do I handle my exceptions in the worker thread so that EndInvoke is
called properly? Async callbacks get the IAsyncResult object passed to them
so it's easy to call EndInvoke, but I don't have that object inside my
worker thread, or at least I don't know how to get to it. So how can I call
EndInvoke when an exception is raised inside my worker thread?
Or am I just completely missing the boat here?
My application spawns a worker process by calling BeginInvoke with an
asynchronous callback method. This callback method is responsible for
calling EndInvoke. No problems there; pretty much straight out of MSDN.
My question is what happens when my worker thread raises an exception? I can
easily catch the exception, but I've noticed that unless my async callback
runs and EndInvoke gets called, then the worker thread never gets returned
to the threadpool. (Which makes perfectly good sense.)
So, how do I handle my exceptions in the worker thread so that EndInvoke is
called properly? Async callbacks get the IAsyncResult object passed to them
so it's easy to call EndInvoke, but I don't have that object inside my
worker thread, or at least I don't know how to get to it. So how can I call
EndInvoke when an exception is raised inside my worker thread?
Or am I just completely missing the boat here?