473,662 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

threading WaitOne()

I have this kind of construct:

Somewhere in thread 1 -------------------------------------------------

SyncLock _objTxRxSync
'code to set some values in _objTxRxSync object
If _objSignal.Wait One(1000, True) Then
'do stuff when other thread signals
Else
'do stuff when timeout
End If
End SyncLock

Somewhere in thread 2 -------------------------------------------------

SyncLock _objTxRxSync
'code to set some values in _objTxRxSync object

_objSignal.Set( )
End SyncLock

--------------------------------------------------------------------------

The problem is that thread 1 never gives up the lock on _objTxRxSync during
the 1000ms wait for thread 2 to access. The documentation states that if the
second parameter for the WaitOne method is set to True, the waiting threat
(thread 1) should give up the lock of the sync context and reaquire it when
signaled by thread 2. Why does this not work? I am using .NET v2.0 latest
release. Is this a bug?
Thanks
Perry

Nov 21 '05 #1
0 914

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

Similar topics

77
5262
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for the moment. I'd be *very* grateful if people with any interest in multi-threading would read it (even just bits of it - it's somewhat long to go through the whole thing!) to check for accuracy, effectiveness of examples, etc. Feel free to mail...
4
2492
by: Perecli Manole | last post by:
I have a background worker thread that receives queued work items and processes them. How do I make this background thread go in a sleep state while the queue is empty and then wake back up as soon as there are work items to be performed? To much processor time is being wasted right now checking an empty queue in a loop. Thanks Perry
17
1441
by: One Handed Man \( OHM - Terry Burns \) | last post by:
Assumes a Form with a Panel on it., Does the Mutex have to be within the address of a thread start address ? Cheers - OHM '----------- *************** ---------------- Private endProgram As Boolean = False Dim image1 As Image = Image.FromFile("..\Images\gun.bmp")
4
1452
by: MS | last post by:
Hi. I'm new to developing and c#. I'm developing a tool that allows a user to select a directory with specially formatted files. The tool then iterates through the list of files in the directory and sends their content via msmq. The part that iterates and sends the files is in a separate thread. I have a button on the form that allows the user to pause or resume the sending of these files. I'm currently using thread.suspend and...
13
1208
by: **Developer** | last post by:
I have a simple need that I can't seem to locate the answer to in the docs. Most examples show how a worker thread can pass data back to the thread that created it. I need to do the opposite. Suppose the worker thread displays a form and the thread that created it wants to change that form's text occasionally.
0
1170
by: archana | last post by:
Hi all, I have some confusion related to threading and autoresetevent. I have 5 threads running for each i have autoresetevent which i am setting through thread procedure. On each of event i am calling waitone as i can't call waithandle.Waitall as i am using STA.
12
5261
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block protecting a resource. Thread 2 and 3 also have a SyncLock block protecting the same resource and after executing some code in their blocks they both do a Monitor.Pulse to hand of the locked resource back to thread 1. While thread 1 has...
6
1315
by: MobileBoy36 | last post by:
Hi All, I want to make a LogFile class that is thread safe. I use a Mutex for it. But the behavior of the class is not that normal. In a c# guide I read you can achieve it by simply using Mutex.Waitone and Mutex.ReleaseMutex. Is that right? What 's wrong with my sub Writelog then? Best regards, Mobileboy
7
2367
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has finished. I am trying to follow this example : http://www.codeproject.com/cs/miscctrl/progressdialog.asp But although the messages still get moved, the progress window never does anything. Here is my code in full, if anybody who knows...
4
14394
by: Lauren Quantrell | last post by:
I have just put together a vb.net app and now need to provide it to users. This application needs to run the code in a sub every 60 seconds from a Windows Service application. I have the functionality of the sub working fine but I cannot figure out how to run the timer. The sub DoSomethingHere() needs to run every 60 seconds. It doesn't need to change the interval or anything like that. It just needs to run every 60 seconds as long as...
0
8435
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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
8857
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...
1
8547
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6186
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
5655
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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
1754
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.