C# - Task Exception not being caught -
i sure doinig wrong, when try example of new threading task exception handling keep getting exception unhandled user code. whole point of code show example of how catch errors in tasks.
link: task exception example
static void main(string[] args) { var task1 = task.factory.startnew(() => { throw new mycustomexception("i'm bad, not bad!"); }); try { task1.wait(); } catch (aggregateexception ae) { // assume know what's going on particular exception. // rethrow else. aggregateexception.handle provides // way express this. see later example. foreach (var e in ae.innerexceptions) { if (e mycustomexception) { console.writeline(e.message); } else { throw; } } } }
most user error not sure (using visual studio 2012);
from page cited:
note
when "just code" enabled, visual studio in cases break on line throws exception , display error message says "exception not handled user code." error benign. can press f5 continue , see exception-handling behavior demonstrated in these examples. prevent visual studio breaking on first error, uncheck "just code" checkbox under tools, options, debugging, general.
Comments
Post a Comment