//call back pattern using System; using - TopicsExpress



          

//call back pattern using System; using System.Runtime.Remoting.Messaging; public delegate void ptr(int a); class sumit { public void sometask(int a1) { Console.WriteLine(a1); } } class shubham { public void ptask() { Console.WriteLine("Called"); } public static void Main() { shubham s = new shubham(); //CLR allocate the Thread sumit s1 = new sumit(); ptr r = new ptr(s1.sometask); IAsyncResult r1=r.BeginInvoke(10,new AsyncCallback(prashant),null);//New Thread is allocated Console.WriteLine("print"); s.ptask(); } static void prashant(IAsyncResult re) { Console.WriteLine("call vback invoked"); AsyncResult res =(AsyncResult)re; ptr s =(ptr)res.AsyncDelegate; s.EndInvoke(re); } }
Posted on: Sun, 25 Aug 2013 11:19:02 +0000

Trending Topics



Recently Viewed Topics




© 2015