473,771 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can WaitOne hang when used with a timeout?

Can any one please offer any theories on how ManualResetEven t.WaitOne
can hang when used with a timeout?

When I notice my USB/Serial devices are no longer receiving
communications, I hit break all, and one of the threads is hanging at:

bool replyReceived =
readerCommand.S ignalReply.Wait One(readerCmd.r xTimeOutMs, false);

Apparently the 1000ms rxTimeOutMs is not working. I have two threads
that wait on this event. This problem has been plaguing me for a long
time. I can not understand how the timeout does not work. If it is a
threading issue, I can not see what it is.

Thanks in advance for any theories or suggestions.

-Ed
May 31 '06 #1
3 10409

"Ed Sutton" <de************ ******@hotmail. com> wrote in message
news:eY******** ******@TK2MSFTN GP02.phx.gbl...
Can any one please offer any theories on how ManualResetEven t.WaitOne can
hang when used with a timeout?

When I notice my USB/Serial devices are no longer receiving
communications, I hit break all, and one of the threads is hanging at:

bool replyReceived =
readerCommand.S ignalReply.Wait One(readerCmd.r xTimeOutMs, false);

Apparently the 1000ms rxTimeOutMs is not working. I have two threads that
wait on this event. This problem has been plaguing me for a long time. I
can not understand how the timeout does not work. If it is a threading
issue, I can not see what it is.

Thanks in advance for any theories or suggestions.

Other than checking whether rxTimeOutMs contains a sane value when you enter
the WaitOne my only suggestion would be to try passing 'true' for the second
parameter.

Andrew
May 31 '06 #2
andrew queisser wrote:
readerCommand.S ignalReply.Wait One(readerCmd.r xTimeOutMs, false);
Other than checking whether rxTimeOutMs contains a sane value when you enter
the WaitOne my only suggestion would be to try passing 'true' for the second
parameter.


Thank you for your reply.

Yes, rxTimeOutMs is set to 1000 milliseconds.

I do not understand why setting the exitContext parameter to true would
make the timeout work as I expect. I expect it to wait until the
ManualResetEven t is signaled or the timeout occurs. The problem is the
timeout elapses yet it is never signaled.

Any additional thoughts are much appreciated.

-Ed
May 31 '06 #3

"Ed Sutton" <de************ ******@hotmail. com> wrote in message
news:OQ******** ******@TK2MSFTN GP03.phx.gbl...
andrew queisser wrote:
readerCommand.S ignalReply.Wait One(readerCmd.r xTimeOutMs, false);

Other than checking whether rxTimeOutMs contains a sane value when you
enter the WaitOne my only suggestion would be to try passing 'true' for
the second parameter.


Thank you for your reply.

Yes, rxTimeOutMs is set to 1000 milliseconds.

I do not understand why setting the exitContext parameter to true would
make the timeout work as I expect. I expect it to wait until the
ManualResetEven t is signaled or the timeout occurs. The problem is the
timeout elapses yet it is never signaled.

Any additional thoughts are much appreciated.


Hi Ed,

Don't really know either, I was just looking at the two parameters to the
function. If you do have a good value for rxTimeoutMs, the only other knob
to play with is the context parameter so I just wanted to make sure you did
try changing that value.

I never fully understood what the exitContext parameter does although I
often use WaitOne. After reading your post I decided it was time to
understand what exitContext means and now I have at least some understanding
of its function. I'm not sure if it really is possible to lead to a deadlock
but perhaps there's another thread running in the same context that the
WaitOne thread was running in. That could lead to a situation where WaitOne
wakes up due to timeout but cannot run because it cannot get into the
context. However, I would expect a deadlock to be more likely when you set
the exitContext to true.

Andrew
Jun 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2056
by: CViniciusM | last post by:
Hello, a) I have a .h (header file) that declares a struct: .... typedef struct { UINT4 state; /* state (ABCD) */ UINT4 count; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer; /* input buffer */ } MD5_CTX; ....
15
2313
by: pranab_bajpai | last post by:
So I want to define a method that takes a "boolean" in a module, eg. def getDBName(l2): .... Now, in Python variables are bound to types when used, right? Eg. x = 10 # makes it an INT whereas
0
1361
by: Tallgeese | last post by:
We developed an in-process COM object for our own application. A toolbar button is used to activate the COM object. But when the COM object loaded, the HTML help hang when clicking the "List Topics" in "Search" tab. The HTML help work nornally without loading the COM. Can anyone provide some starting points, so that I can look at the problem ? Thanks in advacne.
10
3488
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get { return dbConnectionString;
0
1119
by: Severino | last post by:
Hi all, we have developed a .NET component for use inside Windows Forms: this component has been written using VC++.NET (2003) and is working perfectly when inserted inside VC#.NET or VB.NET projects; its generated assembly is inside MyAssembly.dll When used inside a VC++.NET project it appears correctly over forms at design time but when trying to compile the project we get the following error:
0
1456
by: Severino | last post by:
Hi all, we have developed a .NET component for use inside Windows Forms: this component has been written using VC++.NET (2003) and is working perfectly when inserted inside VC#.NET or VB.NET projects; its generated assembly is inside MyAssembly.dll When used inside a VC++.NET project it appears correctly over forms at design time but when trying to compile the project we get the following error:
10
4590
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string (always returns a zero-length string when used in a query expression)" **** How many records are there in FirstTable in which Product Is Null. SELECT COUNT(*) AS CountofNullProdcut
3
1491
by: Greg | last post by:
this template won't compile when used with bool, the erorr is "invalid initialization of non const reference" template < typename T > class Vec : public std::vector< T { public: Vec() { } Vec( int s ) : std::vector<T>(s) { } T& operator(int i) { return this -at(i); } // <- this line
7
2840
by: wingsss | last post by:
i am currently using WindowsXP SP2 all updated apache 2.2.4 PHP 5.2.3 MySQL 5.0 and apache hang up when running this code // ------------------------------------------------------------------------------ function query($query="show tables")
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.