示例#1
0
        static void Main(string[] args)
        {
            var report           = new ComplexReport("42");
            var anotherReport    = new AnotherComplexReport();
            var eventBasedReport = new EventBasedReport();

            //Console.WriteLine("Let's build a report. Press any key to begin");
            //Console.ReadKey();

            //SyncReport(report);
            //AsyncReport(report);
            //MulticastReport(report);
            //ActionReport(report);
            //FuncReport(report);
            //AnotherReportProblem(anotherReport);
            //EventReport(eventBasedReport);
            //AnonymousEventReport(eventBasedReport);
            //LambdaEventReport(eventBasedReport);

            ProcessFun();
            //ThreadsFun();
            //RaceCondition1();
            //RaceCondition2();

            //CancelableReport(report);
            //SeveralReportsSimultaneously();
            //AsyncAwaitReport(report).Wait();

            while (true)
            {
                Console.WriteLine($"Echo: {Console.ReadLine()}");
                tokenSource.Cancel();
            }
        }
示例#2
0
        private static void AnotherReportProblem(AnotherComplexReport report)
        {
            report.ReportBuilt = PrintReportResult;
            report.StartBuilding();

            //можно присвоить совершенного новый объект!!!
            report.ReportBuilt = SendReportResult;
            //или вообще обнулить его!!!
            report.ReportBuilt = null;
            //можно напрямую вызвать делегат!!! все внутренности делегата открыли
            report.ReportBuilt?.Invoke("42432");
        }