Last active
August 29, 2015 14:25
-
-
Save Fhernd/6e27818cf1de839a91fd to your computer and use it in GitHub Desktop.
Uso del método QueueUserWorkItem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
using System; | |
using System.Threading; | |
namespace Receta.Multithreading.R0302 | |
{ | |
public class UsoQueueUserWorkItem | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Environment.NewLine); | |
// Exposición (post) de método asincrónico en | |
// pool de threads: | |
ThreadPool.QueueUserWorkItem(new WaitCallback(MetodoAsincronico)); | |
Console.WriteLine("En `Main` se llevan a cabo otras tareas."); | |
Thread.Sleep(2000); | |
Console.WriteLine(Environment.NewLine); | |
} | |
// Método de ejecución asincrónica: | |
private static void MetodoAsincronico(Object estado) | |
{ | |
Console.WriteLine("\nMensaje desde `MetodoAsincronico`."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment