Comments
7 comments
-
Hello,
If you are using SmartAssembly's error reporting feature, there is an option to "continue" on error. Did you use that option? -
No, not using this option.
-
It must be something to do with the error reporting. .NET Runtime's default behavior is to exit the process on an unhandled exception and SA must be changing the code so that the exception is "handled" as far as .NET is concerned. If you think about it, it would be impossible for SA's exception handling to work if it allowed the runtime to terminate the whole process when an exception is thrown. But you would think that the SA exception handling code would exit the process after displaying the dialog.
-
I think my theory has some validity. SmartAssembly error reporting implements a ThreadExceptionEventHandler, which overrides what the runtime would do (kill the process).
I'll have a look at the code on Monday try to work out what it's actually doing. -
I think the problems is that thread you are creating is a foreground thread.
There are two types of threads in .NET; background threads will automatically get terminated when an application ends, whereas all foreground threads must exit before the application will exit.
Without SA the exception will reach to the JIT debugger which is the only thing that can end all of a processes threads instantly.
SA has to add the code to handle the exception otherwise it would fall to the JIT debugger and the user would get two error messages. The most that SA can do is tell the application to exit in every way possible. It could add some really nasty hacky code which went through and terminated all of the threads in the current process, but this wouldn't handle all of the tidying up (e.g. of unmanaged resources) of the other threads.
Only thing I can really suggest is to make the thread a background thread (thread.IsBackground = true), as usually you don't need a foreground thread. -
True, i wont need a foreground thread. Still its a nasty trap to fall into, even if its not SA's fault. One of those cases where its hard to draw the line. But might be worth at least a warning in the user manual (or even at the settings page).
-
Magic! Thanks Paul!
Add comment
Please sign in to leave a comment.
This is just a really simple app which should just do its job while providing feedback in the background on a separate thread. No big design, just a hack. I reduced the code to the minimum to repro the case.
Without SA the app exits as expected when the exception occurs. With SA it seems to terminate only the main thread.