예제 #1
0
 public void PrintNextReport(PrintInfoCallBack CallBack, object state)
 {
     //Send data back to callback methods identified in CallBack delegate parameter above
     CallBack(PrintStatus.GeneratingReport, state);
     CallBack(PrintStatus.GeneratedReport, state);
     CallBack(PrintStatus.PrintingReport, state);
     CallBack(PrintStatus.PrintingComplete, state);
 }
예제 #2
0
        static void Main()
        {
            ReportPrinter     rp = new ReportPrinter();
            PrintInfoCallBack cb = new PrintInfoCallBack(Program.GetPrintInfo1);

            cb += new PrintInfoCallBack(Program.BackUpPrintInfo);

            //Define anonymous method in place of ThreadStart delegate
            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                rp.PrintNextReport(cb, "First Report");
            });
            t.Start();

            //Define anonymous method in place of ThreadStart delegate
            System.Threading.Thread t2 = new System.Threading.Thread(delegate()
            {
                rp.PrintNextReport(cb, "Second Report");
            });
            t2.Start();

            Console.ReadLine();
        }