472,011 Members | 946 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,011 software developers and data experts.

Max Execution Time on Thread

How can I set the max execution time on a thread? I would like to throw
an exception or indicate a failure if a thread runs longer than x seconds.

Thanks,

Dan Manges
Jun 26 '06 #1
2 4815
Dan,
You can use the WaitHandle.WaitOne overload that takes a timespan /
milliseconds parameter as a simplified thread / method execution timeout
mechanism.

http://msdn2.microsoft.com/en-us/library/85bbbxt9.aspx

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dan Manges" wrote:
How can I set the max execution time on a thread? I would like to throw
an exception or indicate a failure if a thread runs longer than x seconds.

Thanks,

Dan Manges

Jun 26 '06 #2
Peter Bromberg [C# MVP] wrote:
Dan,
You can use the WaitHandle.WaitOne overload that takes a timespan /
milliseconds parameter as a simplified thread / method execution timeout
mechanism.

http://msdn2.microsoft.com/en-us/library/85bbbxt9.aspx


Peter,

That worked perfectly. Thanks!

Dan Manges
Jun 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mark | last post: by
1 post views Thread by Gomaw Beoyr | last post: by
4 posts views Thread by Vlad | last post: by
10 posts views Thread by greenb | last post: by
2 posts views Thread by Justin Powell | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.