By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Timeouts

P: n/a
Let's say I have a method that do something, doesn't matter. Some times it
happens that this method can't finish it's job.

How to implement a kind of Timeout in the calling method, so it doesn't wait
for the called method to finish, but instead generate an error to do
something else, and eventually stop the not responding method?

I was thinking about using threads.

Just wonder isn't there a more appropriate method.

Thanks in advance

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

You can use a Delegate pointing to your method. Use Delegate.BeginInvoke
and store the IAsyncResult object it returns. Then you can use the
IAsyncResult.AsyncWaitHandle.WaitOne method to implement the timeout.

--Robby

"Nikolay Petrov" <jo**************@mail.bg> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Let's say I have a method that do something, doesn't matter. Some times it
happens that this method can't finish it's job.

How to implement a kind of Timeout in the calling method, so it doesn't
wait for the called method to finish, but instead generate an error to do
something else, and eventually stop the not responding method?

I was thinking about using threads.

Just wonder isn't there a more appropriate method.

Thanks in advance

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.