views:

182

answers:

1

I made a software that loads external module made by clients.

This software is supposed to be HA (High availability) meaning it CAN'T be allowed to crash. For that purpose, I created a class which creates a thread, run the client module function in it, and returns. The class allows a certain time to execute the function, and if it takes too long, it kills the thread. Like this, if the client screwed up his module by having an infinite loop or whatever in his code, the rest of the system doesn't freeze.

Now, the question I have...If the thread running the function is created in unmanaged code (C++) and the module function running in it is managed code, what kind of problem could I have by killing the thread?

Thanks,

+2  A: 

In general, it's unsafe to kill a thread in a running process; see the warnings and notes in TerminateThread.

If I were doing such an app, I would be inclined to investigate ways to host the 3rd party module within a separate process with a well-defined communication interface; eg: inside a COM+ application. This would allow you to kill the entire process if it gets "out of control", without affecting the stability of the "host" process.

Nick