.net remoting event timeout -
i have legacy code have maintain uses .net remoting.
the server has send events several clients, works fine except when client hangs, safeinvokemessagearrived ends when client killed.
is there way set timeout in case client freeze return exception in minor time elapsed?
i thought enough changing invoke begininvoke convert call asynchronous
private void safeinvokemessagearrived(string message) { if (!serveractive) return; if (messagearrived == null) return; //no listeners messagearrivedevent listener = null; delegate[] dels = messagearrived.getinvocationlist(); foreach (delegate del in dels) { try { listener = (messagearrivedevent)del; listener.begininvoke(message, new asynccallback(asynccallbackcompleted), listener); } catch (exception ex) { //could not reach destination, remove //from list messagearrived -= listener; } } } protected void asynccallbackcompleted(iasyncresult ar) { try{ messagearrivedevent = (messagearrivedevent)ar.asyncstate; e.endinvoke(ar); } catch(exception ex){ log(ex); } }
Comments
Post a Comment