From 6f814e99f5794ca3a2e00be1797df9ef47171941 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Mon, 20 Nov 2017 21:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=BF=E7=94=A8=E8=80=81=E7=9A=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeighAndGrading/GradeFrom.cs | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index 2c00b73..26e4f4c 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -52,7 +52,7 @@ namespace WeighAndGrading SerialPort weightPort; int maxIndex = 0; ConcurrentQueue noLivestockList; - BackgroundWorker tangWork, maoWork, detailWork; + Thread syncWork; Thread syncToServer; #region weightNeed @@ -71,7 +71,6 @@ namespace WeighAndGrading maoGridView.AutoGenerateColumns = false; maoGridView.DataSource = null; historyGrid.AutoGenerateColumns = false; - InitBackGroundWorker(); if (!Directory.Exists(DATA_PATH)) Directory.CreateDirectory(DATA_PATH); connection = ButcherAppContext.Context.UserConfig.Connection; @@ -86,31 +85,9 @@ namespace WeighAndGrading syncWork.Abort(); if (syncToServer != null && syncToServer.IsAlive) syncToServer.Abort(); - - if (tangWork != null && tangWork.IsBusy) - tangWork.CancelAsync(); - if (maoWork != null && maoWork.IsBusy) - maoWork.CancelAsync(); - if (detailWork != null && detailWork.IsBusy) - detailWork.CancelAsync(); }; } - void InitBackGroundWorker() - { - tangWork = new BackgroundWorker() { WorkerSupportsCancellation = true }; - tangWork.DoWork += delegate { BindTangGridFortangList(); }; - tangWork.RunWorkerCompleted += delegate { BindTangGrid(); }; - - maoWork = new BackgroundWorker(); - maoWork.DoWork += delegate { BindMaoGridFortangList(); }; - maoWork.RunWorkerCompleted += BindMaoGrid(); - - detailWork = new BackgroundWorker(); - //detailWork.DoWork += GetDetailData(); - //detailWork.RunWorkerCompleted += BindDetailGrid(); - } - GradeAndWeight_Detail modifyDetail; void JiBieButtonClick(Button btn) { @@ -254,12 +231,6 @@ namespace WeighAndGrading BindDetailGrid(); if (details.Any()) maxIndex = details.First().Index; - - if (tangWork.CancellationPending) - tangWork.RunWorkerAsync(); - else - tangWork.CancelAsync(); - if (syncWork == null || !syncWork.IsAlive) { syncWork = new Thread(Sync); @@ -389,7 +360,6 @@ namespace WeighAndGrading { maoList = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value, false); } - } catch (TimeoutException) { } } @@ -400,9 +370,9 @@ namespace WeighAndGrading } } + void BindMaoGrid() { - maoGridView.DataSource = maoList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); if (maoEntity == null && maoGridView.CurrentRow != null) {