473,408 Members | 1,809 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,408 software developers and data experts.

How can WaitOne hang when used with a timeout?

Can any one please offer any theories on how ManualResetEvent.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.SignalReply.WaitOne(readerCmd.rxTime OutMs, 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 10360

"Ed Sutton" <de******************@hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP02.phx.gbl...
Can any one please offer any theories on how ManualResetEvent.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.SignalReply.WaitOne(readerCmd.rxTime OutMs, 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.SignalReply.WaitOne(readerCmd.rxTime OutMs, 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
ManualResetEvent 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**************@TK2MSFTNGP03.phx.gbl...
andrew queisser wrote:
readerCommand.SignalReply.WaitOne(readerCmd.rxTime OutMs, 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
ManualResetEvent 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
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...
15
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...
0
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...
10
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...
0
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...
0
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...
10
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...
3
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() { }...
7
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 //...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.