Beispiel #1
0
        void Stop_OnEndLoop(object sender, EndLoopEventArgs e)
        {
            lock (this)
            {
                this.m_nCompleteServerCount++;
            }

            ZConnection connection = this.ZConnections.FindZConnection((Stop)sender);
            int nResultCount = Math.Max(0, connection.ResultCount);
            this.m_nTotalHitCount += nResultCount;

            this.m_connectionDir.ResultCount = this.m_nTotalHitCount;
            this.m_connectionDir.ShowQueryResultInfo("命中结果总数: " + this.m_nTotalHitCount.ToString()
                + (this.m_nCompleteServerCount == this.m_nServerCount ? "" : "..."));

            this.m_stopDir.SetMessage("正在检索。已完成检索的服务器数 " + this.m_nCompleteServerCount.ToString() + " (参与检索服务器总数 " + this.m_nServerCount.ToString() + ")...");

            // 最后一次OnEnd触发
            if (this.m_nCompleteServerCount == this.m_nServerCount)
            {
                this.m_connectionDir.EnableControls(true);

                this.m_stopDir.EndLoop();
                this.m_stopDir.OnStop -= new StopEventHandler(m_stopDir_OnStop);
                // this.m_stopDir.Initial("");

                // 收尾
                this.m_connectionDir = null;
                this.m_stopDir = null;
                this.m_nTotalHitCount = 0;
                this.m_nCompleteServerCount = 0;
                this.m_nServerCount = 0;

                // 解挂全部事件
                for (int i = 0; i < this.m_stops.Count; i++)
                {
                    Stop stop = this.m_stops[i];

                    stop.OnBeginLoop -= new BeginLoopEventHandler(Stop_OnBeginLoop);
                    stop.OnEndLoop -= new EndLoopEventHandler(Stop_OnEndLoop);
                }

                this.m_stops.Clear();
            }
        }
Beispiel #2
0
        //事情做完了,被循环调,里面调了StopManager的Enable()函数,修改按钮为发灰状态
        public void EndLoop()
        {
            if (_inBeginLoop == 0)
                throw new Exception("针对同一 Stop 对象,调用 EndLoop() 不应超过 BeginLoop() 调用次数");

            int nRet = Interlocked.Decrement(ref _inBeginLoop);

            if (nRet == 0)
            {
                nStop = 2;	// 转为 已经停止 状态

                if (m_manager != null)
                {
                    bool bIsActive = m_manager.IsActive(this);

                    this.m_strMessage = "";

                    if (this.OnEndLoop != null)
                    {
                        EndLoopEventArgs e = new EndLoopEventArgs();
                        e.IsActive = bIsActive;
                        this.OnEndLoop(this, e);
                    }

                    if (bIsActive == true)
                    {
                        m_manager.ChangeState(this,
                            StateParts.All | StateParts.RestoreEnabledState,
                            true);
                    }
                    else
                    {
                        // 不在激活位置,不要恢复所谓旧状态
                        m_manager.ChangeState(this,
                            StateParts.All,
                            true);
                    }
                }
            }

            // _inBeginLoop--;
        }
Beispiel #3
0
        //事情做完了,被循环调,里面调了StopManager的Enable()函数,修改按钮为发灰状态
        public void EndLoop()
        {
            nStop = 2;	// 已经停止

            if (m_manager != null)
            {
                bool bIsActive = m_manager.IsActive(this);

                this.m_strMessage = "";

                if (this.OnEndLoop != null)
                {
                    EndLoopEventArgs e = new EndLoopEventArgs();
                    e.IsActive = bIsActive;
                    this.OnEndLoop(this, e);
                }

                if (bIsActive == true)
                {
                    m_manager.ChangeState(this,
                        StateParts.All | StateParts.RestoreEnabledState,
                        true);
                }
                else
                {
                    // 不在激活位置,不要恢复所谓旧状态
                    m_manager.ChangeState(this,
                        StateParts.All,
                        true);
                }
            }
        }