Advertisement
Fhernd

UsoBasicoThreadAbort.cs

Jun 26th, 2014
1,820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace Recetas.Threading.Cap01
  5. {
  6.     internal sealed class UsoBasicoThreadAbort
  7.     {
  8.         public static void Main()
  9.         {
  10.             Thread threadNuevo = new Thread (MostrarMensaje);
  11.            
  12.             if (threadNuevo.IsAlive)
  13.             {
  14.                 // Inicia la ejecución del nuevo thread:
  15.                 threadNuevo.Start();
  16.                
  17.                 // Detiene el thread:
  18.                 threadNuevo.Abort();
  19.             }
  20.            
  21.             // Código ejecutado en el thread Main:
  22.             for (int i = 0; i < 10; ++i)
  23.             {
  24.                 Console.WriteLine ("OrtizOL - xCSw");
  25.             }
  26.            
  27.             Console.WriteLine ("\nEl thread Main ha terminado.\n");
  28.         }
  29.        
  30.         private static void MostrarMensaje ()
  31.         {
  32.             for (int i = 0; i < 10; ++i)
  33.             {
  34.                 Console.WriteLine ("Recetas Multithreading en C#");
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement