call back design pattern executable code is passed as an argument to other code and it is expected to call back at some time.
using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; namespace program { class Example { static void Main(string[] args) { CallBackdemo callBackdemo = new CallBackdemo(); callBackdemo.Test(); Console.ReadLine(); } } public class CallBackdemo { public void Test() { TaskCompletedCallBack callback = TestCallBack; CallBack testCallBack = new CallBack(); testCallBack.NewTask(callback); } public void TestCallBack(string result) { Console.WriteLine(result); } } public delegate void TaskCompletedCallBack(string Result); public class CallBack { public void NewTask(TaskCompletedCallBack taskCompletedCallBack) { Console.WriteLine("I have started new execution Task."); if (taskCompletedCallBack != null) taskCompletedCallBack("I have completed execution Task."); } } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
call back design pattern executable code is passed as an argument to other code and it is expected to call back at some time.