コード例 #1
0
 //Exit
 private void Exit_Click(object sender, EventArgs e)
 {
     DbCancelation.Cancel();
     ReadCancelation.Cancel();
     IEDConnected = false;
     Closedb();
     Form.ActiveForm.Close();
 }
コード例 #2
0
ファイル: RelayManagment2.cs プロジェクト: benvert/pfe
        //Lecture des bools de la DB
        private void DbReading(CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                toolStatus.Text = "Cancellation thrown"; return;
            }
            if (!Dbisopen)
            {
                Opendb();
            }
            this.Invoke((MethodInvoker)(() => dataGridView.Rows.Clear()));
            if (TableExists("vinTable", database_connection))
            {
                string sql = "SELECT valeur FROM vinTable ";
                cmd = new SQLiteCommand(sql, database_connection);
                try
                {
                    using (SQLiteDataReader read = cmd.ExecuteReader())
                    {
                        int index = 0;
                        while (read.Read())
                        {
                            Valeur[index] = read.GetBoolean(0);

                            index++;
                        }
                        read.Close();
                    }
                    ValeurOPC = Valeur;
                }
                catch (Exception er)
                {
                    this.Invoke((MethodInvoker)(() => db_status.Text = er.Message));
                    ReadCancelation.Cancel();
                }
            }
        }