Exemplo n.º 1
0
        void Lock_End(object state, bool timedout)
        {
            Reset_SO stateObj = (Reset_SO)state;

            try
            {
                stateObj.UpdateContext();
                if (timedout)
                {
                    string msg = string.Format("Unable to lock CC within {0} time: ", stateObj.Timeout);
                    NSTrace.WriteLineError(msg + Environment.StackTrace);
                    stateObj.Exception = GetTimeoutException(stateObj.Timeout);
                    stateObj.SetCompleted();
                }
                else
                {
                    try
                    {
                        Cmd_RunDTP curDTP = _client.CurrentDTP;
                        if (null != curDTP)
                        {
                            curDTP.Reset();
                        }
                    }
                    finally
                    {
                        _cc.Unlock();
                    }

                    //----------------------------------------
                    //Wait till DTP finishes
                    _client.BeginWaitForDTPFinished(stateObj.Timeout,
                                                    new WaitOrTimerCallback(DTPFinishedWait_End),
                                                    stateObj);
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }
Exemplo n.º 2
0
        internal void Execute(int timeout)
        {
            bool finished = false;

            //---------------------------------
            //Lock CC
            if (_cc.Lock(timeout))
            {
                //------------------------------------------
                //Reset DTP
                try
                {
                    Cmd_RunDTP curDTP = _client.CurrentDTP;
                    if (null != curDTP)
                    {
                        curDTP.Reset();
                    }
                }
                finally
                {
                    _cc.Unlock();
                }

                //------------------------------------------
                //Wait till DTP exits
                finished = _client.WaitForDTPFinish(timeout);
                if (!finished)
                {
                    string msg = string.Format("DTP is not finished withing {0} time: ", timeout);
                    NSTrace.WriteLineError(msg + Environment.StackTrace);
                    throw GetTimeoutException(timeout);
                }
            }
            else
            {
                string msg = string.Format("Unable to lock CC within {0} time: ", timeout);
                NSTrace.WriteLineError(msg + Environment.StackTrace);
                throw GetTimeoutException(timeout);
            }
        }