Questions tagged [waitone]

29 questions
12
votes
3 answers

How do I unblock threads which have called the WaitOne method on an AutoResetEvent object?

Below is a class having the method 'SomeMethod' that illustrates my problem. class SomeClass { AutoResetEvent theEvent = new AutoResetEvent(false); // more member declarations public void SomeMethod() { // some code …
ghd
  • 258
  • 1
  • 3
  • 14
6
votes
2 answers

WaitOne() waits forever even though all events fired

Threaded is suppossed to create 4 seperate threads and wait for each of them till they finish. Each thread sleeps for a while and terminates only when the shared Mutex opbject is not occupied by another thread and then signal trough a event that it…
4
votes
1 answer

Does calling WaitOne using a Semaphore release the calling thread to perform other work?

My application needs to perform a number of tasks per tenant on a minute-to-minute basis. These are fire-and-forget operations, so I don't want to use Parallel.ForEach to handle this. Instead I'm looping through the list of tenants, and firing off a…
Gary
  • 742
  • 8
  • 20
2
votes
2 answers

How to wait for a BackgroundWorker to finish to run another BackgroundWorker (C#)?

First of all, I'm still a beginner, so I'd appreciate it if you could have some patience :) I've been scratching my head so hard today about this. The thing is, I want to run three different backgroundworkers. But I would like to wait until one has…
dgls61
  • 21
  • 3
2
votes
1 answer

Release and WaitOne in Semaphore in C#

I'm working on semaphore using C#. The following is my understanding about the Release and WaitOne methods in C#. The WaitOne method decreases the semaphore count when a thread enters a slot and when it leaves the slot, the semaphore is…
vishnu
  • 511
  • 1
  • 7
  • 10
2
votes
2 answers

How best to dispose a thread that is sleeping because of AutoResetEvent.WaitOne()

I have a windows service that sends email in a one of 5 threads (done to increase the speed the service can send email): private AutoResetEvent block; private ThreadedQueue messageQueue; private void DoSend() { try { …
Lawrence Phillips
  • 289
  • 1
  • 3
  • 12
1
vote
2 answers

One event wait for other event to occur

So... The user has to click on the button, after he clicks it, the program should wait for another click on Panel and get the coordinates of that click. But as soon as I click the button, everything becomes unresponsive. Am I doing something wrong? …
Matej
  • 75
  • 10
1
vote
1 answer

Spurious wake-up of WaitOne() in C#

There are two CRITERIA in my program which decides whether a thread should wait or continue. First Criterion: Change in an XML file. I have a file watcher which sets an AutoResetEvent (_waitTillXmlChanges.Set()) if the XML file changes and hence…
skm
  • 5,015
  • 8
  • 43
  • 104
1
vote
0 answers

Functionality of ManualResetEvent.WaitOne with 0 time out argument

I was dealing with code that has some calls to ManualResetEvent's WaitOne call. From the MSDN documentation, If timeout is zero, the method does not block. It tests the state of the wait handle and returns immediately. Now, this is my piece of…
Cygnus
  • 3,222
  • 9
  • 35
  • 65
1
vote
3 answers

Regarding WaitOne() method of Mutex Type

I have written a small piece of code. something like below public static void SetLicence1() { Console.WriteLine("Setting Aspose Licence in Thread1 "); Console.WriteLine(SetAsposeLicense()); } public static…
Nivedita
  • 11
  • 1
  • 3
1
vote
2 answers

How can I use WaitHandle awaiting completion of an asynchronous call?

Consider this code: class Program { static void Main(string[] args) { Master master = new Master(); master.Execute(); } } class TestClass { …
Alexandr
  • 1,891
  • 3
  • 32
  • 48
1
vote
1 answer

Messaging using BeginReceive and EndReceive on ServiceBus does not work for me

I need asynchronous messaging on the bus. This is the code I'm using: //set callback to get the message MessageReceiver messageReceiver = MessagingFactory.CreateMessageReceiver(BaseTopicName + "/subscriptions/" + addressee, …
0
votes
1 answer

Webservice : AsyncCall finished : But WaitOne() still waiting

I am calling a WebService method via a Command Line Exe. This method call is Async Call and I am using WaitOne after the Call. I am doing ManualRest.Set() in completed method. The above setup works fine 99% of the cases where the async method…
0
votes
1 answer

How to pause a thread at once in C#?

I use ManualResetEnvent to pause/continue a thread. The code example is below. private _rstEvent = new ManualResetEvent(true); public void DoSomeWork() { while(judgementValue) { _rstEvent.WaitOne(); ... } } public void…
Dream Land
  • 31
  • 5
0
votes
3 answers

How can I wait the response and do operations with it?

I have one new problem. I want to do some operations with the response, but I get a NullReferenceException, because it isn't arrived yet... Here is my code: public partial class MainPage : PhoneApplicationPage { public static string res =…
laszlokiss88
  • 4,001
  • 3
  • 20
  • 26
1
2