Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
AutoResetEvent número de subprocesos en espera .net 5.0

Estoy usando AutoResetEvent. Solo necesito saber si es posible obtener el número de subprocesos en espera.

 if (WaitHandler.Reset()) { if (WaitHandler.WaitOne(WaitMilliseconds)) { // do something after WaitHandler.Set() } }

Necesito saber cuántos subprocesos están esperando actualmente en WaitOne(). ¿Y es posible limitarlos, como 10 subprocesos como máximo, todos los demás subprocesos retroceden? Si no, ¿cómo limitarlo?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No estoy seguro de si esto es útil, lo encontré en https://kmyr.dev/post/limiting-the-number-of-threads

 internal sealed class ThreadManager { private readonly WaitHandle[] _syncObjects; public ThreadManager() : this(Environment.ProcessorCount) { } public ThreadManager(int maxThreads) { MaxThreads = maxThreads; _syncObjects = new WaitHandle[maxThreads]; for (var i = 0; i < maxThreads; i++) { _syncObjects[i] = new AutoResetEvent(true); } } public int MaxThreads { get; private set; } public bool StartTask(Action action, bool wait) { var timeout = wait ? Timeout.Infinite : 0; var freeIndex = WaitHandle.WaitAny(_syncObjects, timeout); if (freeIndex == WaitHandle.WaitTimeout) { return false; } ThreadPool.QueueUserWorkItem( state => { action(); ((AutoResetEvent)state).Set(); }, _syncObjects[freeIndex]); return true; } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!