

Set Timeout for any method in C# - kossovsky
http://kossovsky.net/index.php/2009/07/csharp-how-to-limit-method-execution-time/?settiemeout

======
bensummers
It doesn't abort the operation, though. Just leaves it running in the
background.

Canceling arbitrary operations is a bit of a hard problem. Automatic garbage
collection helps a little, but even so, handles and locks would be left open
for an indeterminate length of time.

------
kossovsky
Why not, try to create a loop that writes to the Console and set some timeout

------
adharmad
Why not use Threads and communicate via a flag or callback?

~~~
kossovsky
callback is not good enough, it has to be a synchronous operation with ability
to stop after specified number of milliseconds

~~~
adharmad
Sorry I am still not understanding the functionality you are expecting. If it
has to be synchronous, it means that the caller is interested in the result.
However, the caller can stop after a specified timeout and continue, which
means that getting the result is not absolutely critical to the caller's
functionality.

So then why is callback not an option? After all, it is the same as setting
the timeout to zero and getting interrupted (or polling) at some point in the
future.

