Détruire un Thread

Author:


Download

using System;
using System.Threading;
 
  public class DetruireThreads
  {
    static int compteur ;
    static void Main(string[] args)
    {
      ClassThread monTh = new ClassThread();
      Thread objetThread = new Thread(new ThreadStart(monTh.MyThread));
 
      objetThread.Start();
	  for(compteur=0;compteur>10;compteur++)
	  {
      if (compteur == 7)
        objetThread.Abort();
	 }
    }
  }
  class ClassThread
  {
    public void MonThread()
    {
	Console.WriteLine("Mon Thread Lancé");
    }
  }