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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
public Chauffe()
{
InitializeComponent();
btn_exit.Enabled = false;
// Déclaration et Instanciation du thread
Thread myThread = new Thread(new ThreadStart(ThreadLoop));
// Lancement du thread
myThread.Start();
}
public void ThreadLoop()
{
int i = 0;
int cp_bon = 1;
byte[] buffer1 = new byte[1];
DIO.SetPort(0);
do
{
Thread.Sleep(200);
DIO.ReadByte(buffer1);
Thread.Sleep(300);
if (buffer1[0].ToString() == "224" | buffer1[0].ToString() == "160")
{
cp_bon = cp_bon + 1;
i++;
}
else
{
cp_bon = 1;
i = 0;
}
// pour sortir
if (cp_bon == 5)
i = 20;
//MessageBox.Show("i = " + i.ToString() + " / buffer = " + buffer1[0].ToString() );
}
while(i < 10);
ChangeForm();
}
public void ChangeForm()
{
// impossible d'effectuer cette tache !
// conclusion il plante ici !
btn_exit.Enabled = true;
} |