コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="owningTask"></param>
        /// <remarks>
        /// 可能包含读取并清除本地数据的后续指示(在Task.Tag中)
        /// </remarks>
        private void ProcessReadTotalCountCmd(ReadTotalCountCommand cmd, Task owningTask)
        {
            if (owningTask.Tag != null)
            {
                object[] tags = owningTask.Tag as object[];
                if (tags != null && tags.Length == 2)
                {
                    TagType tagType = (TagType)tags[0];
                    XGTask  xgtask  = (XGTask)tags[1];


                    //Immediate task strategy 被加到tasks的最前端,所以要先加入,一般在读取完所有的记录后清空。
                    //
                    RemoveAllCommand clearCmd  = new RemoveAllCommand(cmd.Station as XGStation);
                    Task             clearTask = new Task(clearCmd, new ImmediateTaskStrategy());
                    clearTask.Tag = xgtask;
                    clearTask.BeforeExecuteTask += new EventHandler(clearTask_BeforeExecuteTask);
                    Singles.S.TaskScheduler.Tasks.Add(clearTask);

                    for (int i = 0; i < cmd.TotalCount; i++)
                    {
                        ReadRecordCommand rdcmd = new ReadRecordCommand(cmd.Station as XGStation, i + 1);
                        Task t = new Task(rdcmd, new ImmediateTaskStrategy());
                        Singles.S.TaskScheduler.Tasks.Add(t);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="owningTask"></param>
        /// <remarks>
        /// 可能包含读取并清除本地数据的后续指示(在Task.Tag中)
        /// </remarks>
        private void ProcessReadTotalCountCmd(ReadTotalCountCommand cmd, Task owningTask)
        {
            int recordCount = cmd.TotalCount;

            if (recordCount <= 0)
            {
                return;
            }

            XGStation st = (XGStation)cmd.Station;

            //Immediate task strategy 被加到tasks的最前端,所以要先加入,一般在读取完所有的记录后清空。
            //
            RemoveAllCommand clearCmd  = new RemoveAllCommand(st);
            Task             clearTask = new Task(clearCmd, new ImmediateTaskStrategy());

            Singles.S.TaskScheduler.Tasks.Add(clearTask);

            for (int i = 0; i < recordCount; i++)
            {
                ReadRecordCommand rdcmd = new ReadRecordCommand(st, i + 1);
                Task t = new Task(rdcmd, new ImmediateTaskStrategy());
                Singles.S.TaskScheduler.Tasks.Add(t);
            }
        }
コード例 #3
0
ファイル: frmControl.cs プロジェクト: wwkkww1983/bt
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="address"></param>
        private void XGClear(string remoteIP, int address)
        {
            XGStation xgst = GetXGStation(remoteIP, address);

            if (xgst != null)
            {
                RemoveAllCommand cmd = new RemoveAllCommand(xgst);
//                Task t = new Task( cmd, new ImmediateTaskStrategy () );
//                Singles.S.TaskScheduler.Tasks.Add ( t );
//                frmControlProcess f = new frmControlProcess( t );
//                f.ShowDialog();
                this.CreateImmediateTaskAndExecute(cmd);
            }
        }