Вопрос

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