on 2016 Mar 23 8:34 PM
Hello everyone.
When I throw an exception inside an event, B1 disconnects the add-on. Is there any way to find out that this happened?
I did some tests and even when the addon got disconnected I still can send messages via MessageBox for example. The only difference that I saw is that B1 does not send events anymore.
I need to know when this happens because the application will still run after being disconnected, so I need to kill the task to avoid many executables running for nothing.
Thank you in advice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leandro,
Your addon gets disconnected because it threw an unhandled exception. It's good practice to run event handlers inside a try/catch block and process any exceptions coming from the event handler.
Note that by preventing unhandled exception to propagate, you don't need to know "when" the addon gets disconnected to kill the task, since you won't get disconnected.
Of course it also good practice to log the exception somehow.
Good luck.
Best regards,
Pedro Magueija
Please lets focus on my question.
I know that and all my event handlers are under try/catch block.
The point is that sometimes a developer can forget the try/catch statement in a task or separeted thread and we have some costumers which use cloud servers complaining about more than one instance of our addon running for the same user.
All I need is to develop some method to prevent this from happen when we have some bug in our code.
Hi Leandro,
Have a look at: AppDomain.UnhandledException Event (System)
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
That will make sure that any Unhandled exception thrown in your application will get caught by this handler.
Best regards,
Pedro Magueija
User | Count |
---|---|
106 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.