internal static readonly TimerThread THREAD = LoadTimerThread(); // LUCENENET: Avoid static constructors (see https://github.com/apache/lucenenet/pull/224#issuecomment-469284006) private static TimerThread LoadTimerThread() { var thread = new TimerThread(Counter.NewCounter(true)); thread.Start(); return(thread); }
public void openCam() { TimerThread.Enabled = true; TimerThread.Start(); fuenteVideo = new VideoCaptureDevice(ball[CameraComboBox.SelectedIndex].MonikerString); VideoViewer.VideoSource = fuenteVideo; VideoViewer.Start(); }
static TimerThreadHolder() { THREAD = new TimerThread(Counter.NewCounter(true)); THREAD.Start(); }
static TimeLimitedCollector() { { TIMER_THREAD.Start(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (null == _item) { return; } _MAX_CAM = Global.deviceHole.SxtCount - 1; _listSampleNum = new List <TextBox>(); int sampleNum = _item.SampleNum; int holeUse = 0; // 添加布局 for (int i = 0; i < Global.deviceHole.SxtCount; ++i) { UIElement element = GenerateChannelLayout(i, String.Format("{0:D5}", sampleNum), _item.Hole[i].SampleName); WrapPanelChannel.Children.Add(element); if (_item.Hole[i].Use) { holeUse += 1; sampleNum++; _listSampleNum.Add(UIUtils.GetChildObject <TextBox>(element, "sampleNum")); } else { element.Visibility = System.Windows.Visibility.Collapsed; _listSampleNum.Add(null); } } if (holeUse < 4) { if (holeUse == 1) { this.WrapPanelChannel.Width = 190; } else if (holeUse == 2) { this.WrapPanelChannel.Width = 380; } else if (holeUse == 3) { this.WrapPanelChannel.Width = 570; } } // 初始化辅助方框及TC线的参数 _bTCLineNeedSetting = new bool[Global.deviceHole.SxtCount]; _helpBoxes = new HelpBox[Global.deviceHole.SxtCount]; for (int i = 0; i < _bTCLineNeedSetting.Length; ++i) { _bTCLineNeedSetting[i] = false; _helpBoxes[i] = new HelpBox(); } // 初始化灰阶值存储位置 _bRGBValuesNeedRead = new bool[Global.deviceHole.SxtCount]; _listRGBValues = new List <byte[]>(); for (int i = 0; i < _bRGBValuesNeedRead.Length; ++i) { _bRGBValuesNeedRead[i] = false; _listRGBValues.Add(null); } // 启动线程 _updateCAMThread = new UpdateCAMThread(this); _updateCAMThread.Start(); _bTimerWork = true; _msgReadCAMReplyed = true; _timerThread = new TimerThread(this); _timerThread.Start(); Message msg = new Message() { what = MsgCode.MSG_TIMER_WORK }; _timerThread.SendMessage(msg, null); }
private void timer1_Tick(object sender, EventArgs e) { DT_Now = DateTime.Now; if (VideoViewer.GetCurrentVideoFrame() != null) { BarcodeReader Reader = new BarcodeReader(); Bitmap img = new Bitmap(VideoViewer.GetCurrentVideoFrame()); //----------------加入CV--------------------- //Image<Gray, byte> I = new Image<Gray, byte>(img); //Image<Bgr, byte> DrawI = I.Convert<Bgr, byte>(); //Image<Gray, byte> CannyImage = I.Clone(); //灰階處理 //CvInvoke.GaussianBlur(I, CannyImage, new Size(5, 5), 0); //CvInvoke.Canny(I, CannyImage, 100, 200); //MyCV.BoundingBox(CannyImage, DrawI); //pictureBox1.Image = DrawI.Bitmap; //pictureBox2.Image = CannyImage.Bitmap; //Result result = Reader.Decode(DrawI.Bitmap); //----------------CV end---------------------- Result result = Reader.Decode(img); //原本 img.Dispose(); //釋放資源 if (result != null) { Scan_result_richTextBox.SelectionColor = Color.Green; Scan_result_richTextBox.AppendText("[" + DT_Now + "] 掃描條碼顯示: " + result + Environment.NewLine); //Scan_result.Items.Add("DBconnection = " + connectionString); //資料庫(自動Dispose寫法) String check_psd = "SELECT * FROM staff_info WHERE Encode_ID = '" + result + "'"; using (OleDbCommand cmd = new OleDbCommand()) { DataSet ds = new DataSet(); Table_Row TBR = new Table_Row(); List <Table_Row> table_row = new List <Table_Row>(); //OleDbDataReader dr; cmd.Connection = Access_DataBase.DB_Conn_Open(connectionString_StaffDB); cmd.CommandText = check_psd; //dr = cmd.ExecuteReader(); OleDbDataAdapter adapter = new OleDbDataAdapter(cmd); try { adapter.Fill(ds, "Encode_ID"); adapter.Fill(ds, "Name"); adapter.Fill(ds, "Sex"); adapter.Fill(ds, "Job"); adapter.Fill(ds, "Phone"); adapter.Fill(ds, "CarNumP"); adapter.Fill(ds, "Photo"); try { TBR.Id = ds.Tables["Encode_ID"].Rows[0]["Encode_ID"].ToString(); TBR.Name = ds.Tables["Name"].Rows[0]["Name"].ToString(); TBR.Sex = ds.Tables["Sex"].Rows[0]["Sex"].ToString(); TBR.Job = ds.Tables["Job"].Rows[0]["Job"].ToString(); TBR.CarNumP = ds.Tables["CarNumP"].Rows[0]["CarNumP"].ToString(); TBR.CarNumP = ds.Tables["Phone"].Rows[0]["Phone"].ToString(); TBR.Photo = (byte[])ds.Tables["Photo"].Rows[0]["Photo"]; table_row.Add(TBR); ds.Tables.Clear(); string Table_name = DT_Now.ToString("yyyy_MM"); Check_Table_Exsits(Access_DataBase.DB_Conn_Open(connectionString_QRcode_Scan), cmd, Table_name);//檢查有無當月Table沒有建立 ShowInfo SI_form = new ShowInfo(table_row, this, Table_name, connectionString_QRcode_Scan); } catch { TimerThread.Stop(); string message = "此條碼可能被註銷,或者不是岡山榮家發行"; string caption = "查無此資料"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult DiaResult = MessageBox.Show(message, caption, buttons); //MessageBox.Show(message, caption, buttons); if (DiaResult == DialogResult.OK) { TimerThread.Start(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } }
public void OnServerOpen() { TimerThread.Start(); AddHandler(); AddUpdate(); }