Questions tagged [manualresetevent]

ManualResetEvent notifies one or more waiting threads that an event has occurred

ManualResetEvent notifies one or more waiting threads that an event has occurred

References

136 questions
2
votes
0 answers

Drawbacks with embedding event handlers in methods

Sometimes when I use assemblies that have an asynchronous approach for interaction (you call a method and then you get an event back with the answer) I like to convert them to synchrounus methods by embedding the event handler in the method. The…
Patrik B
  • 151
  • 1
  • 13
2
votes
1 answer

How do I wake up a thread at a specified time in objective-c

I'm writing an ssh wrapper in objective-c, I'm trying to implement a maxTime a command should take to execute. The way I implement it is: Main Thread: calculate timeout create asyncThread (GCD queue) to execute command and parse the returned…
1
vote
1 answer

Reading twice from FileStream

I have a GetServiceMap() method which calls deserializer who then opens the stream and reads something from it. The problem is that i have a GetAllGroups() method also who calls deserializer over the same stream. How would i syncronize it? With…
Bip
  • 893
  • 5
  • 14
  • 29
1
vote
1 answer

What could cause EventWaitHandle.Set() to block the current thread?

I am invoking the Set method on an instance of a ManualResetEvent, and it is occasionally deadlocking. I can't find anything in the documentation to indicate that this is a blocking method. What could cause MRE.Set to block? Stack Trace: [Managed…
chilltemp
  • 8,854
  • 8
  • 41
  • 46
1
vote
2 answers

Why isn't the BeginGetResponse callback being called?

Here's my code: namespace RequestApi { public partial class MainPage : PhoneApplicationPage { private BackgroundWorker bw; private string ans; private JObject ansJson; private static ManualResetEvent allDone =…
1
vote
1 answer

How to repeatedly listen to serial port DataReceived event for timeout no buffer received?

I have a serial port connection to weighing indicator(display) that connecting to the scale. The device B has 3 state: No Power(Plug off) Power On(Plug on but not power up) Display Ready(after press power up) On any state, I can connect to serial…
Luiey
  • 843
  • 2
  • 23
  • 50
1
vote
1 answer

Dictionary of ManualResetEvent - ThreadSafety

I'm synchronizing some threads using a dictionary of ManualResetEvents. It looks something like this. My question is, Is it thread-safe to call a getter/indexer of the dictionary like this? Should I call the getter from the context of a lock and…
stevep
  • 167
  • 1
  • 7
1
vote
0 answers

ManualResetEvent.WaitOne() with 0 timeout returns unexpected false although event was set

I have a class that wraps ManualResetEvent (see in the code sample below) During my application flow I call the WaitOne method with a 0 parameter a few times. It returns true as expected, except for one particular check that returns false although…
avmerber
  • 11
  • 2
1
vote
0 answers

Why does the connection get disposed before WaitAsync completes?

I'm having a problem with DBus usage. I'm trying to get a notification bubble with a few action buttons up and running. So far, I've been able to get the bubble to show with retValue = await proxy.NotifyAsync( and get the button that has been…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
1
vote
0 answers

how I stop all threads using manualResetEvent or any other suggestion to stop my all threads?

I am using 10 threads each thread get 10 records whose Status is null and then update status to "Q". Now these records is requested to different APIs and on success response i update the status to "C" all is doing nicely. As a stopper to stop all…
1
vote
4 answers

Better approach to concurrently "do or wait and skip"

I wonder is there a better solution for this task. One have a function which called concurrently by some amount of threads, but if some thread is already executing the code the other threads should skip that part of code and wait until that thread…
ilivit
  • 41
  • 1
  • 7
1
vote
2 answers

Strange behaviour of C# .NET ManualResetEvent after PC startup

I've recently noticed very strange behaviour of ManualResetEvent class in .NET framework. I am using C#, VS 2015, project's target is set to 4.5.2. Here is the full code: using System; using System.Diagnostics; using System.Threading; using…
iamnp
  • 510
  • 8
  • 23
1
vote
1 answer

Using UnsafeRegisterWaitForSingleObject failed with exception when exiting app?

I'm trying to use ThreadPool.UnsafeRegisterWaitForSingleObject to notify if some app exits. It works at least at what I want but right after I close the main form, it throws the exception: SEHException : External component has thrown an…
Hopeless
  • 4,397
  • 5
  • 37
  • 64
1
vote
0 answers

what exactly happens when ManualResetEvent.WaitOne is called?

Recently I came across an MSDN link which says that the ManualResetEventSlim class can be used for better performance when compared to ManualResetEvent class. "In the .NET Framework 4, you can use the System.Threading.ManualResetEventSlim class for…
1
vote
1 answer

windows service using shutdown event cant stop the service

I've written a windows service that attempts to read messages from an MSMQ and process them. I have added an installer to my project, and I have set the startup to manual. I install the service and then start it through the Services tool. I can…
bilpor
  • 3,467
  • 6
  • 32
  • 77