I am doing a project where I am loading several assemblies during runtime, for each of those assemblies I use reflection to find some specific classes, instantiate them and calling their methods. All this is working fine, but for some of the calls the process encounters a stack overflow which terminates my entire program. I don't have any control over the source code of the assemblies I am loading so I cant change the code I'm executing.
What I have tried to solve the problem:
I assign a thread to do the invocation of the methods and tried to
abort the thread after a timeintervall(I know that this is bad practice but I cant change the code to terminate friendly). This however doesn't work, I think the thread is to busy "stackoverflowing" to handle the Abort-call.Ive tried reducing the actual memory the thread has access to, this is not even a solution because you cant catch the stackoverflow-exception so my program terminates anyway (just quicker)
Questions:
- Can a thread be to busy to be aborted? Is there some way to abort a thread that is having this behaviour?
- How can we call code (that we don't have any control over) in a good way?
Thanks in advance!