c# - How should I gracefully handle faulty AppDomains? -
Is this code snippet poorly designed? Basically, there was only one AppDomain.Unload
, finally in the block. Due to its unfathenetate side effects, other threads could keep running in the AppDomain while UnhandledException
was running, which uses user input from other things and therefore is very slow on the computing scale (average actual Runtime can be> 1min), possibly throwing other exceptions and generally causing more problems. I am stuck on thinking about a 'better' way of doing it, therefore, I lend it to my mind.
Note: I realized that there are also synchronization issues. Yes, I know what they are, stay focused.
mainApp = AppDomain.CreateDomain (ChildAppDomain, Blank, AppDomain.CurrentDomain.SetupInformation); Try {mainApp.ExecuteAssembly (assembly.net Entry Assembly (.).); Ends = true; } Hold (Exception Pre) {AppDomain.Unload (mainApp); MainApp = null; Unrestricted Exception (this, new unfade expansion event (pre, wrong)); } Finally {if (mainApp! = Tap) {AppDomain.Unload (mainApp); MainApp = null; }} // ... zero exception without exception (Object Sender, UnhandledExceptionEventArgs e) {if (mainApp! = Null) {AppDomain.Unload (mainApp); MainApp = null; } // [snip]}
I will not try any repetition and IoO , You can do this task only with the Appdomain cleaning in the block at the end, as you did initially. The idea is that if there is an uncontrolled exception, keep it in a variable and then process it after shutting down the appdomain
Exceptions unrestricted Exception = null; {...} hold (ex before) {unhandledException = ex; } Finally {cleanupwordsdomain (main app); } If (uncontrolled exception! = Null) unrestricted exception (this, new unhandled expansion events (unrestricted exception, wrong));
Comments
Post a Comment