Asynchronous Calls : Asynchronous : Thread C# Examples


C# Examples » Thread » Asynchronous »

 

Asynchronous Calls









    
using  System;

delegate  void  FuncToCall(string  s);
class  MainClass
{
        
        
        public  static  void  WriteLineCallback(IAsyncResult  iar)
        {
                Console.WriteLine("In  WriteLineCallback");
                FuncToCall  func  =  (FuncToCall)  iar.AsyncState;
                func.EndInvoke(iar);
        }
        
        public  static  void  CallWriteLineWithCallback(string  s)
        {
                FuncToCall  func  =  new  FuncToCall(Console.WriteLine);
                func.BeginInvoke(s,  new  AsyncCallback(WriteLineCallback),  func);
        }

        public  static  void  Main()
        {
                CallWriteLineWithCallback("Hello  There");
                
                System.Threading.Thread.Sleep(1000);
        }
}
    
   
  
   



Output

Hello There
In WriteLineCallback


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Thread
» Asynchronous