I call Office PIA to do something, but always word process hangs and CPU usage is 0%.

How to add a timeout mechanism?

or saying, stop the word process after a expiration time?

有帮助吗?

解决方案 2

Wrote a program to monitor the word process and kill it when timeout.

其他提示

AFAIK - there is no timeout mechanism. You would need to implement it manually.

Implement IDisposable in your class where you are calling the Office PIA. In the Dispose, kill the office process.

Not sure how you are calling the office PIA, if you are calling it with using()... it should not sit there..

I don't know if this is relevant anymore but here it goes:

document.Close(ref Missing, ref Missing, ref Missing);
app.Quit(ref Missing, ref Missing, ref Missing);

PS: this is for Microsoft Word. I believe same can be achieved with other applications using the Quit method.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top