Bonjour, je voudrais comprendre pourquoi ce petit bout de code ne marche pas:
En effet, lorsque je tente de faire aForm.Dodo();
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; namespace Test_appli_graph { public partial class Form2 : Form { Form1 aForm; public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Thread my_Thread; my_Thread= new Thread(new ThreadStart(Traitement)); my_Thread.Start(); Thread.Sleep(3000); aForm.Dodo(); } private void Traitement() { Application.Run(aForm=new Form1()); } } }
Il me lève une exception selon laquelle aForm n'est pas instancié, alors que je l'instancie dans mon Thread.start();,
Et là je comprends pas ce qui bug,...
Partager