0

How to put the IDispatch::Invoke to a thread and call TerminateThread if it timeouts?

The reason I wanted to do this is because I find that sometimes the Invoke call will go into infinity loop and never return anything and hence the call will just sit there for forever. Hence, I am thinking of putting the Invoke to a thread and terminate the thread when it timeout.

Any advices or references are really appreciated. Peace

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794

1 Answers1

0

Hi i strongly do not recommend you call TerminateThread for any others things but TerminateThread + IDispatch::Invoke can cause abnormal program termination in good case and more strange program behavior and random crashes in bad one. I think you need chose another way...

Sanja Melnichuk
  • 3,465
  • 3
  • 25
  • 46
  • Hi Sanja, Thank you for your reply and advice. Yes, I had read in google not to call TerminateThread and the Invoke together. But, aside from creating Thtread, I could not think or find other way to determine the timeout of the IDispatch::Invoke and the call for the function will sit there for forever. – user652785 Mar 13 '11 at 23:20