Esempio n. 1
0
        private void WorkerThreadLoop()
        {
            // Mark the ThreadLocal to tell this is a worker
            isWorkedThread = true;

            try
            {
                do
                {
                    while (TryCooperate())
                    {
                    }

                    semaphore.Wait();

                    if (disposing > 0)
                    {
                        return;
                    }
                } while (true);
            }
            finally
            {
                if (disposing == 0)
                {
                    // If this thread is aborted or errored, spin up a new thread prior to stopping
                    CreateWorkerThread();
                }
                else
                {
                    Interlocked.Decrement(ref leftToDispose);
                }
            }
        }
Esempio n. 2
0
        private void WorkerThreadScope()
        {
            isWorkedThread = true;
            try
            {
                do
                {
                    while (TryCooperate())
                    {
                    }

                    if (disposing > 0)
                    {
                        return;
                    }

                    semaphore.Wait();
                } while (true);
            }
            finally
            {
                if (disposing == 0)
                {
                    NewWorker();
                }
                else
                {
                    Interlocked.Decrement(ref leftToDispose);
                }
            }
        }
Esempio n. 3
0
        private void WorkerThreadScope()
        {
            isWorkedThread = true;
            try
            {
                do
                {
                    while (TryCooperate())
                    {
                    }

                    semaphore.Wait();
                } while (true);
            }
            finally
            {
                NewWorker();
            }
        }