Ejemplo n.º 1
0
        /// <summary>
        /// Invoke the action that we want to run on a thread.
        /// </summary>
        protected void ProcessPoolItem(object state)
        {
            ThreadSemaphore <ProcessCall> ts = (ThreadSemaphore <ProcessCall>)state;

            while (true)
            {
                ts.WaitOne();
                ProcessCall rc;

                if (ts.TryDequeue(out rc))
                {
                    Call(rc);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Invoke the action that we want to run on a thread.
        /// </summary>
        protected void ProcessPoolItem(object state)
        {
            ThreadSemaphore <ProcessCall> ts = (ThreadSemaphore <ProcessCall>)state;

            while (!stopThreads)
            {
                ts.WaitOne(100);
                ProcessCall rc;

                if (ts.TryDequeue(out rc))
                {
                    // Call(rc);

                    // TODO: As absurd as this is, we're trying to isolate a problem where the
                    // threads stop processing their work!
                    // Task.Run(() =>
                    {
                        try
                        {
                            rc.MakeCall();
                        }
                        catch (Exception ex)
                        {
                            Exception ex2 = ex;
                            // Prevent recursion if the exception process itself throws an exception.
                            if (!(rc.SemanticInstance is ST_Exception))
                            {
                                try
                                {
                                    ProcessInstance(Logger, new ST_Exception(ex), true);
                                }
                                catch { }
                            }
                        }
                    }// );
                }
            }
        }