News for hackers. Stuff that matters.
Re:Set Timeout for any method in C# by bensummers on Thursday July 16, 2009 @07:25AM (#707671)
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.

Re:Set Timeout for any method in C# by kossovsky on Thursday July 16, 2009 @07:46AM (#707700)
Why not, try to create a loop that writes to the Console and set some timeout
Re:Set Timeout for any method in C# by adharmad on Thursday July 16, 2009 @09:16AM (#707853)
Why not use Threads and communicate via a flag or callback?
Re:Set Timeout for any method in C# by kossovsky on Thursday July 16, 2009 @09:55AM (#707918)
callback is not good enough, it has to be a synchronous operation with ability to stop after specified number of milliseconds
Re:Set Timeout for any method in C# by adharmad on Friday July 17, 2009 @10:16PM (#711244)
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.