Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/6e27818cf1de839a91fd to your computer and use it in GitHub Desktop.
Save Fhernd/6e27818cf1de839a91fd to your computer and use it in GitHub Desktop.
Uso del método QueueUserWorkItem.
// 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