Exemple #1
0
        private void GridBlinkThreadFunc()
        {
            while (true)
            {
                // Make a copy to avoid invalid operation exception while iterating through the map
                List <CellData> tempBlinkData;
                lock (_blinkData)
                {
                    tempBlinkData = new List <CellData>(_blinkData);
                }

                foreach (CellData data in tempBlinkData)
                {
                    TimeSpan elapsed = DateTime.Now - data.Time;
                    if (elapsed.TotalMilliseconds > 500) // 500 is the Blink delay
                    {
                        if (UG1.IsDisposed)
                        {
                            return;
                        }

                        UG1.Invoke((MethodInvoker) delegate()
                        {
                            foreach (DataGridViewRow DR in UG1.Rows)
                            {
                                if (DR.Cells[5].Value.ToString() != "ISSUED")
                                {
                                    DR.Cells[0].Style.BackColor = UG1.Columns[0].DefaultCellStyle.BackColor;
                                    DR.Cells[1].Style.BackColor = UG1.Columns[1].DefaultCellStyle.BackColor;
                                    DR.Cells[2].Style.BackColor = UG1.Columns[2].DefaultCellStyle.BackColor;
                                    DR.Cells[3].Style.BackColor = UG1.Columns[3].DefaultCellStyle.BackColor;
                                    DR.Cells[4].Style.BackColor = UG1.Columns[4].DefaultCellStyle.BackColor;
                                    DR.Cells[5].Style.BackColor = UG1.Columns[5].DefaultCellStyle.BackColor;
                                    DR.Cells[6].Style.BackColor = UG1.Columns[6].DefaultCellStyle.BackColor;
                                }
                            }
                        });

                        lock (_blinkData)
                        {
                            _blinkData.Remove(data);
                        }
                    }
                }

                Thread.Sleep(1000); // Blink frequency
            }
        }
Exemple #2
0
        private void DataInputThreadFunc()
        {
            while (true)
            {
                if (UG1.IsDisposed)
                {
                    break;
                }



                CellData data = new CellData();

                data.Time = DateTime.Now;



                UG1.Invoke((MethodInvoker) delegate()
                {
                    //UG1.Rows[data.Row].Cells[data.Col].Value = value;
                    foreach (DataGridViewRow DR in UG1.Rows)
                    {
                        if (true)
                        {
                            if (DR.Cells[5].Value.ToString() != "ISSUED")
                            {
                                DR.Cells[0].Style.BackColor = Color.Yellow;
                                DR.Cells[1].Style.BackColor = Color.Yellow;
                                DR.Cells[2].Style.BackColor = Color.Yellow;
                                DR.Cells[3].Style.BackColor = Color.Yellow;
                                DR.Cells[4].Style.BackColor = Color.Yellow;
                                DR.Cells[5].Style.BackColor = Color.Yellow;
                                DR.Cells[6].Style.BackColor = Color.Yellow;
                            }
                        }
                    }
                });

                lock (_blinkData)
                {
                    _blinkData.Add(data);
                }

                Thread.Sleep(2000);
            }
        }