Question Locked

Timeout pattern

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Have couple applications that makes some tests, but sometimes these applications can freeze (using MAPI). Need to develop pattern that will terminate the application, after some period of time. I think that it is already done buy somebody, so looking for nice solution. Can somebody provide with information about how to achieve this?

Thanks

2 replies

by tony hopkinson

You kick off the iffy routine in another thread and start a timer.
if the routine completes successfully it kills the timer.
If the timer event fires you have a timeout.

The real fun is closing gracefully.

You need to get a bit cleverer if you can have muliple operations which may time out, but then you've got to decide what to do with the others.

Note the thread where the OnTimeout code excecutes can't be the one that is blocked by the timedout operation.
Sounds obvious, but an extraordinary amount of people forget that bit.

This discussion is closed to new replies.