[Mono-list] Catching exceptions in ClientSink (Aync processing)

paszczi paszczi at go2.pl
Thu Jul 17 04:41:09 EDT 2008


Yes this would be ideal ... but not in case of client channel sink. When I get asyn response from the server AsyncProcessResponse is called, There I need to perform some operations and call next sink to process the message with:
nextSink.AsyncProcessRequests() however this doesn't return any state at all :( and I don't have access to any methods that would End this processing (a'la EndInvoke)
Typically you do something like this:
1) Create a class like:
public class MyAsyncResult : AsyncReult
{
 internal Exception SavedException;
}
2) When the user starts an asyncronous request, instantiate one of those classes and return it as the IAsyncResult.
3) Keep a reference to this object during your asynchronous processing
4) If an exception is thrown, store it in the SavedException property and complete the request (typically set AsyncResult.Complete =true, signal the wait handle and invoke the AsyncCallback if one was supplied)
5) This should result in the user calling the EndXXX method and pass in the IAsyncResult that you created at the start
6) Just check if SavedException != null, and if that's true, rethrow the exception
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080717/fcd1a9f5/attachment.html 


More information about the Mono-list mailing list