class Program
{
static void Main()
{
Thread t = new Thread(ShowMessage);
t.Start();
Console.WriteLine("Start For");
for (var i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
Console.WriteLine("End For");
Console.ReadKey();
}
/// <summary>
/// 模拟异步
/// </summary>
static void ShowMessage()
{
Console.WriteLine("async Start For");
for (var i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Console.WriteLine(i);
}
Console.WriteLine("async End For");
}
}
{
static void Main()
{
Thread t = new Thread(ShowMessage);
t.Start();
Console.WriteLine("Start For");
for (var i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
Console.WriteLine("End For");
Console.ReadKey();
}
/// <summary>
/// 模拟异步
/// </summary>
static void ShowMessage()
{
Console.WriteLine("async Start For");
for (var i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Console.WriteLine(i);
}
Console.WriteLine("async End For");
}
}