Esempio n. 1
0
        /// <summary>
        /// -启动发送数据
        /// </summary>
        private void Start()
        {
            this.btnStart.Enabled = false;
            if (logined)
                this.btnStop.Enabled = true;

            if (!AutoStart)
                Page_Load();
            try
            {
                if (FirstStart == false)
                {
                    FirstStart = true;
                    GatherData = new GatherData();
                    mq = new MQ();//创建消息队列

                    //数据发送 
                    SendDataThread = new System.Threading.Thread(new System.Threading.ThreadStart(StartSend));
                    SendDataThread.IsBackground = true;
                    SendDataThread.SetApartmentState(System.Threading.ApartmentState.STA);

                    //网络状态发送
                    SendStateThread = new System.Threading.Thread(new System.Threading.ThreadStart(StartStateSend));
                    SendStateThread.IsBackground = true;
                    SendStateThread.SetApartmentState(System.Threading.ApartmentState.STA);

                    SendDataThread.Start();
                    SendStateThread.Start();

                    //发送在内存中分析后的结果
                    Analys analy = new Analys();
                    analy.StartAnaly();
                }
                else
                    SendDataThread.Resume();
                mq.CoalCode = GatherData.CoalCode;
                this.lblStatus.Text = "煤矿编号:" + GatherData.CoalCode + " 煤矿名称:" + initConfig.CoalName + " 系统运行中";
            }
            catch (System.Threading.ThreadStartException ex) { Tcs.Libary.Log.Write("多线程(MainForm)异常:" + ex.ToString()); }
            catch (System.Exception ex) { Tcs.Libary.Log.Write("程序(MainForm)异常:" + ex.ToString()); }
        }