473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 4874
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
Hello all, I know why the following doesn't work ... I can't figure out how to make it work like I want it to. Basically, I only want the loop computing fibonacci numbers to run for approx 5...
30
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to...
3
by: omission9 | last post by:
Any advice on the following would be much appreciated. I have thrown everything I have at it and am completely stumped. I apologize for the length, I have tried to be as succint as possible. I...
1
by: Gomaw Beoyr | last post by:
When the BeginInvoke method of a delegate is called, the execution of the delegate is in another thread. (I'm not sure if an entirely new thread is created, or if a "sleeping" thread is used.) ...
4
by: Vlad | last post by:
I have implemented an asyncrhonous execution of a method using the delegate's BeginInvoke() I am trying to spin multiple worker threads in a thread pool. Here is the code: TestProcess process =...
1
by: Jack Wright | last post by:
Dear All, I have observed that if I call a synchronous WebService from my aspx page then even if I set oProxy.TimeOut = 1000, the WebService thread execution is still running... Since my...
10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
17
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also...
2
by: Justin Powell | last post by:
Hi, I'm looking for suggestions on how to accomplish something in python. If this is the wrong list for such things, I appologize and please disregard the rest. My application needs to allow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.