static void Main(string[] args) { string filePath = @"c:\windows\system32\drivers\etc\HOSTS"; ReadAllTextDelegate func = File.ReadAllText; func.BeginInvoke(filePath, actionCompleted, func); Console.ReadLine(); }
static void Main(string[] args) { //string text = File.ReadAllText(@"C:\windows\system32\drivers\etc\HOSTS"); //Console.WriteLine(text); string filePath = @"C:\windows\system32\drivers\etc\HOSTS"; // 델리게이트를 이용한 비동기 처리 ReadAllTextDelegate func = File.ReadAllText; func.BeginInvoke(filePath, actionCompleted, func); Console.ReadLine(); // 비동기 스레드가 완료될 때까지 대기하는 용도 }