Questions tagged [event-wait-handle]

51 questions
5
votes
2 answers

what's the proper way to tell a thread that is executing a loop to break out of the loop and do something else?

The following code has the disadvantage that the worker thread will neither terminate immediately nor perform a final action after the main thread resets the waithandle. Instead, it will continue doing what it is doing until it reaches the next…
John Smith
  • 4,416
  • 7
  • 41
  • 56
3
votes
0 answers

How can I get the name used to open an EventWaitHandle?

I am trying to implement a cross-process event architecture where processes can "subscribe" to events, and then "unsubscribe". My initial tests using EventWaitHandle are promising (although I've read some negative comments about them, but please…
3
votes
1 answer

Is it safe to call .Close (.Dispose) on an EventWaitHandle directly after .Set?

I have one thread waiting on an EventWaitHandle (AutoResetEvent): AutoResetEvent.WaitOne(); I have another thread signalling the first thread to continue AutoResetEvent.Set(); AutoResetEvent.Close(); Is it safe to call .Close direct after .Set, in…
Edwin
  • 527
  • 7
  • 15
3
votes
1 answer

How should I implement the C# server side portion of long-polling for ajax requests?

I've got an architecture that involves browsers polling via ajax every 3 seconds for updates and I'd like to change that to long-polling. I'd like to have 1, 2.. {n} clients long-polling, waiting for updates and have something happen on the server…
Allen Rice
  • 19,068
  • 14
  • 83
  • 115
3
votes
1 answer

How to detect whether an EventWaitHandle is waiting?

I have a fairly well multi-threaded winforms app that employs the EventWaitHandle in a number of places to synchronize access. So I have code similar to this: List _revTypes; EventWaitHandle _ewh = new EventWaitHandle(false,…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
2
votes
1 answer

Is it possible to check whether System.Threading.EventWaitHandle can be opened without throwing exceptions?

I have try { using (var eventWaitHandle = EventWaitHandle.OpenExisting(name)) { eventWaitHandle.Set(); } Environment.Exit(0); } catch(WaitHandleCannotBeOpenedException) { // register new handle code goes here } Is there…
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
2
votes
1 answer

Using EventWaitHandle class

in Process A I need to receive an event from Proces B. I decided to use EventWaitHandle. In both processes i write this code: var evhandle = new EventWaitHandle(false, EventResetMode.AutoReset,"MyGUID1221"); then in process A i invoke Set()…
WelcomeTo
  • 19,843
  • 53
  • 170
  • 286
2
votes
1 answer

How can I use EventWaitHandle to create an event?

I'm writing a program that listens on a Serial Port. I already have code that utilizes the VCP drivers (Virtual COM Port) to open a serial connection and then add an event handler for any time data is received. That code roughly looks like…
soapergem
  • 9,263
  • 18
  • 96
  • 152
2
votes
1 answer

Is it possible to restrict set/reset of EventWaitHandle?

I would like to have EventWaitHandle object (eg. ManualResetEvent) that can be set/reset from only one place but that can be waited for (with WaitOne()) from multiple places. Put it differently, I want to have just one class that can set/reset it…
matori82
  • 3,669
  • 9
  • 42
  • 64
2
votes
1 answer

Using an event wait handle to block for window closed, then wrapping as async-await. Acceptable?

I have a window displaying service, with a CloseWindow method that is called by the view. I want to create a blocking method in my calling code. So I can block while a window pops up and to allow outputs to come back from the window. Is this use of…
2
votes
1 answer

Confuse about the name of EventWaitHandle

Considering below code snippet for MyServer side public void CreateEvent() { var serverReadyEvent = new EventWaitHandle(false, EventResetMode.AutoReset, "aaa"); } After search from MSDN, the 3rd parameter of the ctor means name Type:…
Carlos Liu
  • 2,348
  • 3
  • 37
  • 51
2
votes
2 answers

.NET system-wide EventWaitHandle name allowed characters

I'm just curious off hand, are there any restrictions on the naming of a system-wide EventWaitHandle? I want to use a URL as the name for one, but it could have a great deal of odd characters, I don't want it to silently fail or some other such, so…
Jimmy Hoffa
  • 5,909
  • 30
  • 53
2
votes
2 answers

How to run number of processes in bunches of thread without using threadPool & used EventWaitHandler for Handling

class Process { static void Main(string[] args) { int threads = 0; int processes = 0; Console.WriteLine("Total number of processes:"); processes = Convert.ToInt32(Console.ReadLine()); …
huda
  • 4,107
  • 2
  • 21
  • 24
2
votes
5 answers

How to know if EventWaitHandle.Set was invoked

Is there a way to know which EventWaitHandle was invoked. i have two custom class with 2 different System Wide Event names. The reason I had them is to distinguish which function to trigger. The problem I have right now is how can I distinguish…
Juvil
  • 490
  • 12
  • 26
2
votes
1 answer

Process management and EventWaiter in Java

I'm going to implement a small daemon application in Java. Below is my requirement. Could someone please give me some suggestion on how to do it? To start and monitor another process (restart it if it is crashed) Run on both Windows and Linux (SUSE…
Miles Chen
  • 793
  • 1
  • 10
  • 20
1
2 3 4