I'm writing a chess game which enables two programs compete, the ball player must write a DLL and expose a function to inform the primary application where his player will move next, imagine that the function appears like this
public static void MoveNext(out int x, out int y, out int discKind)
The player's DLL could be written using C# or C++.
Within the chess game application, I begin a new thread to call the function the player's DLL uncovered to obtain where he'll relocate a turn, and that i begin a timer to avoid the ball player timeouts, if your player timesout i'll get rid of the corresponding thread by using APIs
I've the next issues as referred to below:
The thread can't be wiped out with 100% assurance (it is dependent about the player's code)
Throughout test I discovered that, when the player utilizes a deep recursions (and when there's memory leak within the player's program), the memory using the host application increases and so the host application is going to be ended with no exceptions.
What are the techniques, ideas or techniques that may handle the above mentioned issues?
Out of this CodeInChaos recommended to load player's DLL into separate domain after which unload it at the appropriate interval, I don't know whether it still works best for the unmanaged DLL (C++) and when it'll result in a low efficiency?
An unhandled exception within their AppDomain will still cause your program to terminate insInternet 2.. You receive a chance to reply to the exception with an event handler although not a chance to handle it.
Your best choice is by using approaches for the type of isolation you are searching for.
If you are able to ensure your wordpress plugin DLL's will always be handled code, then you've a choice of createing a brand new application domain inside your primary application logic and loading the set up that contains the wordpress plugin into that domain.
This then provides you with a choice of trapping unhandled excpetions in that specific application domain and also you then have the choice of Unloading that whole application domain. That method for you to deal with other bands application plug ins acting up and tossing exceptions. additionally you gain a choice of indicating partial trust to help restrict such a wordpress plugin can perform.
However this can not help if you fail to enforce using handled code plug ins, and also the earlier use of some seperate processes could be more apropriate.
Reading through your publish agin it appears you've some quality difficulties with the plug ins you need to use. Should you must deal with such buggy plug ins I'd go ahead and take previous advice and opt for seperate processes.