c# - What happens to an exception in an async method if EndInvoke is never called? -
let's have following code:
private delegate void deadlydelegate(); private void deadly() { throw new exception("die!"); } public void dostuff() { deadlydelegate d = deadly; d.begininvoke(null, null); }
now, there has been discussion if endinvoke() needed (and answer yes), i'm not asking that. let's whatever reason, endinvoke never reached (in example, don't call it, imagine other reasons of how accidentally not ever called).
first question: happens exception? disappear , never cause problems? or thrown unhandled exception during garbage collection, same way task exceptions if never observed? i've done searching, both google , so, , haven't found answer this.
in own code, of course plan call endinvoke(). nice know happens if, because of unanticipated program path, endinvoke somehow isn't called. don't want whole app come crashing halt because of unhandled exception (if there one).
second question: whatever answer first question, same true of built-in async calls in .net framework, tcpclient.beginconnect()? if method throws exception, disappear if never call endconnect(), or can still cause problems?
third question: (this should trivial, thought i'd double check) there way sort of strange unhandled/unobserved exception can happen in async code between begininvoke/connect , endinvoke/connect calls? or guaranteed exceptions safely propagate point endinvoke/connect called?
Comments
Post a Comment