Exemplo n.º 1
0
        /// <summary>
        /// Execute a thread on a dedicated Executor.
        ///
        /// Right before the execution the thread's status is set the Scheduled
        /// and the thread's executor is set to the executor's ID.
        /// Spawn a new thread that remotes the execution to the Executor.
        ///
        /// </summary>
        /// <param name="ds">Containes the Thread ID and the Executor ID.</param>
        /// <returns>True if the thread was successfully started on the Executor.</returns>
        public bool ExecuteThread(DedicatedSchedule ds)
        {
            bool    success = false;
            MThread mt      = new MThread(ds.TI);

            try
            {
                /// [email protected] - Feb 28, 2006:
                /// moved the thread status updating here from ManagerContainer.StartDispatch
                /// to make sure that the thread state is written in the right order
                mt.CurrentExecutorId = ds.ExecutorId;
                mt.State             = ThreadState.Scheduled;

                logger.Debug(String.Format("Dispatching thread {0} to executor: {1}", ds.TI.ThreadId, ds.ExecutorId));

                // [email protected] - Jul 17, 2006: changed to parameterized thread start.
                ExecuteCurrentThreadParameters oParameters = new ExecuteCurrentThreadParameters(ds.TI, mt);
                Thread dispatchThread = new Thread(new ParameterizedThreadStart(this.ExecuteCurrentThread));
                dispatchThread.Name = "ScheduleDispatchThread";
                dispatchThread.Start(oParameters);

                success = true;
            }
            catch (Exception ex)
            {
                // restore the thread status so another executor can pick it up
                mt.CurrentExecutorId = null;
                mt.State             = ThreadState.Ready;

                logger.Debug("Error scheduling thread on executor " + _Id, ex);
            }

            return(success);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the current thread.
        /// </summary>
        /// <param name="oObject">execute current thread parameters</param>
        private void ExecuteCurrentThread(object oObject)
        {
            // [email protected] - Jul 17, 2006: added exception handling; fix for bug 1523762.
            ExecuteCurrentThreadParameters oParameters = (ExecuteCurrentThreadParameters)oObject;

            try
            {
                this.RemoteRef.Manager_ExecuteThread(oParameters.ThreadIdentifier);
            }
            catch (Exception oException)
            {
                // restore the thread status so another executor can pick it up
                oParameters.MThread.CurrentExecutorId = null;
                oParameters.MThread.State             = ThreadState.Ready;

                logger.Debug("Error scheduling thread on executor " + _Id, oException);
            }
        }