public void execute() { MouvementStock ms = new MouvementStock(); ms.articlesEnStock(); ms.processAvailableArt(); ms.makeProposition(); List <String[]> result = ms.displayAppro(); foreach (String[] row in result) { if (dataGridView1.InvokeRequired) { dataGridView1.Invoke(new Action(delegate() { dataGridView1.Rows.Add(row); })); } else { dataGridView1.Rows.Add(row); } } //fin de traitement if (dataGridView1.InvokeRequired) { dataGridView1.Invoke(new Action(delegate() { dataGridView1.Rows[0].Selected = false; button1.Enabled = true; panel1.Enabled = true; encours.Visible = false; })); } else { dataGridView1.Rows[0].Selected = false; button1.Enabled = true; panel1.Enabled = true; encours.Visible = false; } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { MouvementStock ms = new MouvementStock(); execute(); }