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
0
votes
2 answers

Implement a capped and buffered job executor

I want to implement a capped and buffered job executor. It will have a single method: public class CappedBufferedExecutor { public CappedBufferedExecutor(int bufferCapping, int fillTimeInMillisec); public Task EnqueueAsync(string…
Mugen
  • 8,301
  • 10
  • 62
  • 140
0
votes
2 answers

ManualResetEventSlim and Lock

I have a piece of data that takes quite a lot of time to fetch. I have different ways of figuring out if new data should be fetched or if I can use my current "cache" theResult When someone asks for that piece of data I want to be able to both do a…
svrist
  • 7,042
  • 7
  • 44
  • 67
0
votes
1 answer

ManualEventReset - wait for any of both

Consider that I have passed two ManualEventReset instances public void MyApiCall(ManualResetEvent ev1, ManualResetEvent ev2) { //my code } Now, I have to 'WaitOne' for any of both (no matter which of them, I need to to continue as soon as one of…
pwas
  • 3,225
  • 18
  • 40
0
votes
1 answer

c# multiple threads waiting for a ManualResetEvent

I'm messing around with multithreading and making some sort of task engine. The idea is that the engine can have a configurable amount of threads waiting and when a new task arrives the first free thread picks it up and executes it. The problem is…
Jan Korf
  • 58
  • 10
0
votes
1 answer

How to wait for ManualResetEvent.WaitOne() to be reached before moving on?

I'm trying to use ManualResetEvent to make a semaphore-like situation and I have placed WaitOne, Set and Reset in their right places. The WaitOne instruction is called in a listener thread and is places right after a tcp reading: var networkStream =…
0
votes
1 answer

ManualResetEvent throws NullReferenceException: Object reference not set to an instance of an object

The code throws NullReferenceException: Object reference not set to an instance of an object on the line ((ManualResetEvent)handles[i]).Set(). I checked handles[i] has a value when I debug it. What am I doing wrong? ` string[]…
0
votes
1 answer

Parallel programming with ManualResetEvent

I have one method to handle a List parallel. Unfortunately I can't use .NET 4+. But when I run this method, i is always items.Count public static void ParallelForEachTest(List items) { if (items != null && items.Count > 0) …
Impostor
  • 2,080
  • 22
  • 43
0
votes
1 answer

ManualResetEvent is not working as expected - Form is hanging

I have written a class that uses a worker thread and it utilises an event object. I have cut the class down to the basics: using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Threading; using…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
1 answer

Changing async call implementation using a ManualResetEvent to one using a combination of Thread methods

I'm looking for a design pattern to switch from using a ManualResetEvent to using Thread methods like Thread.Join. Right now I'm making an async call and then using a ManualResetEvent to wait till the async call finishes before continuing on the…
Fung
  • 7,530
  • 7
  • 53
  • 68
0
votes
2 answers

await any async method and (event or boolean)

I have this code : ManualResetEvent EventListenerStopped; ... while (true) { IAsyncResult iar = this.ListenerHttp.BeginGetContext(ProcessRequest, null); if (WaitHandle.WaitAny(new[] { this.EventListenerStopped, iar.AsyncWaitHandle }) == 0) …
0
votes
1 answer

How to use ManualResetEvent to replace boolean flags in this class

I have made a previous question with the same code, and have been advised to use ManualResetEvent, because it is the right way of doing what I want, and I agree with that. Problem is: I have read and re-read the docs and a lot of tutorials about…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
0
votes
1 answer

Threading ...start/suspend ..set/reset

I have been trying to modify an app developed by other in past ... this app does online trading ( using api developed for C#)..so basically i have the app structure where i set few configuration paramter which user can check or uncheck and there is…
MrPandav
  • 1,831
  • 1
  • 20
  • 24
0
votes
1 answer

Timer in foreach with ManualResetEvent

When I click the button, the cycle starts to read the database and send each row of the query to another server. When get response - the cycle continues. Code is implemented as follows private ManualResetEvent _mre = new…
alexander
  • 195
  • 3
  • 13
0
votes
1 answer

ManualResetEvent Skipped by thread

Here I have a block of code that executes: public override void Execute(XObjectList itemList, ProcessInfo processInfo) { ManualResetEvent syncEvent = new ManualResetEvent(false); execute(itemList, processInfo); …
svbyogibear
  • 333
  • 1
  • 5
  • 19
0
votes
1 answer

Will ManualResetEvent block the entire program?

I have a program that begins itself by listening for connections. I wanted to implement a pattern in which the server would accept a connection, pass that individual connection to a user class for processing: future packet reception, and handling of…
Fuselight
  • 554
  • 6
  • 17