开发者

How do I know which "single use" out-proc COM server process to restart if it hangs?

I need to run some native C++ code in such way that if it crashes it doesn't affect my C# progr开发者_开发知识库am. I can use an out-proc COM server with "single use" activation so that each COM object instance is hosted in a separate process.

Now I create a set of worker threads and each creates an instance of that COM object. I also create a "watchdog" thread that will look after the worker threads.

Suppose the watchdog thread notices that the latest call to the out-proc object has been running for two days already and this likely means that the object code has just hung. So it wants to restart the process and needs the process id for that. How does it find the process id?

The dumb way I can think of is that the object implements an interface with GetProcessId() method and the client calls that method and stores the process id.

What other ways are there?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜