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
| private void LaunchApp()
{
strProcess = textBox1.Text;
strStartApp = textBox2.Text;
do
{
// pause de 3 secondes = 3000 ms
Thread.Sleep(3000);
// on lance l'application si elle n'existe pas
if (Process.GetProcessesByName(strProcess).Length <= 0)
{
try
{
Process.Start(strStartApp);
}
catch { }
}
// check if thread is cancelled
if (m_EventStopThread.WaitOne(0, true))
{
// inform main thread that this thread stopped
m_EventThreadStopped.Set();
return;
}
// fin boucle quand processus a demarre
} while (Process.GetProcessesByName(strProcess).Length > 0);
} |
Partager