PostgreSQL
- 1 ответ
- 0 вопросов
1
Вклад в тег
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static async Task MethodDelayAsync()
{
Console.WriteLine("1. MethodDelayAsync: before await thread id: {0}", Thread.CurrentThread.ManagedThreadId);
await Task.Delay(1000);
Console.WriteLine("2. MethodDelayAsync: after await thread id: {0}", Thread.CurrentThread.ManagedThreadId);
}
static async Task MethodTaskRunAsync()
{
Console.WriteLine("1. MethodTaskRunAsync: before await thread id: {0}", Thread.CurrentThread.ManagedThreadId);
await Task.Run(() =>
{
Console.WriteLine("Asynchronous operation in MethodTaskRunAsync in thread id: {0}",
Thread.CurrentThread.ManagedThreadId);
});
Console.WriteLine("2. MethodTaskRunAsync: after await thread id: {0}", Thread.CurrentThread.ManagedThreadId);
}
static void Main(string[] args)
{
Console.WriteLine("Start Main in thread id: {0}", Thread.CurrentThread.ManagedThreadId);
//MethodDelayAsync();
MethodTaskRunAsync();
Console.WriteLine("End Main in thread id: {0}", Thread.CurrentThread.ManagedThreadId);
Console.Read();
}
}
}