コールバック関数実行スレッドについて
2824 ワード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
public delegate void PrintCallback(int i);
static void Main(string[] args)
{
PrintCallback pcb = new PrintCallback(Print);
for (int i = 0; i < 1000; i++)
{
ExcetCallback(pcb, i);
Console.WriteLine(" ; ID " + System.AppDomain.GetCurrentThreadId());
}
}
public static void ExcetCallback(PrintCallback pcb,int i)
{
pcb(i);
}
public static void Print(int i)
{
Console.WriteLine(" " + i + " ; ID " + System.AppDomain.GetCurrentThreadId());
Thread.Sleep(10000);//10s
}
}
}