}
try {
return TryReceiveRequest (tout, out ctx);
+ } catch (XmlException ex) {
+ Console.WriteLine ("Xml Exception (Dropped Connection?):" + ex.Message);
+ //on dropped connection,
+ //whatever you do don't crash
+ //the whole app. Ignore for now
+ } catch (SocketException ex) {
+ Console.WriteLine ("Socket Exception (Dropped Connection?):" + ex.Message);
+ //on dropped connection,
+ //whatever you do don't crash
+ //the whole app. Ignore for now
+ } catch (IOException ex) {
+ Console.WriteLine ("I/O Exception (Dropped Connection?):" + ex.Message);
+ //on dropped connection,
+ //whatever you do don't crash
+ //the whole app. Ignore for now
} finally {
lock (async_result_lock) {
- CurrentAsyncResult = null;
- CurrentAsyncThread = null;
+ currentAsyncResults.Remove (result);
+ currentAsyncThreads.Remove (Thread.CurrentThread);
}
}
+ ctx = null;
+ return false;
});
RequestContext dummy;
- IAsyncResult result;
lock (async_result_lock) {
- result = CurrentAsyncResult = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
+ result = try_recv_delegate.BeginInvoke (timeout, out dummy, callback, state);
+ currentAsyncResults.Add (result);
}
- // Note that at this point CurrentAsyncResult can be null here if delegate has run to completion
+ // Note that at this point result can be missing from currentAsyncResults here if delegate has run to completion
return result;
}