Пример #1
0
        private void datacollect()
        {
            List <string> Namelist = new List <string>();

            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                Namelist.Add(this.listView1.Items[i].SubItems[0].Text.ToString());
            }
            while (true)
            {
                if (this.flag == true)
                {
                    break;
                }
                //Action<int> actionDelegate = delegate(int txt) { opc.AsyncReadItems(Namelist); };
                //this.listView1.BeginInvoke(actionDelegate, 1);
                opc.AsyncReadItems(Namelist);
                Thread.Sleep(1000);
            }
        }
Пример #2
0
        private void datacollect() //OPC数据获取
        {
            List <string> Namelist = new List <string>();

            for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
            {
                Namelist.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString().Substring(0, this.dataGridView2.Rows[i].Cells[0].Value.ToString().Length - 1));
            }
            while (true)
            {
                if (this.flag == true)
                {
                    break;
                }
                //Action<int> actionDelegate = delegate(int txt) { opc.AsyncReadItems(Namelist); };
                //this.dataGridView1.BeginInvoke(actionDelegate, 1);
                opc.AsyncReadItems(Namelist);
                Thread.Sleep(60000);
            }
        }