Exemple #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();
            }
        }
Exemple #2
0
        private static void LambdaEventReport(EventBasedReport eventBasedReport)
        {
            eventBasedReport.OnReportBuilt += result => Console.WriteLine($"Lambda report result: {result}");
            eventBasedReport.OnReportBuilt += PrintReportResult;
            eventBasedReport.OnReportBuilt += SendReportResult;

            eventBasedReport.StartBuilding();
        }
Exemple #3
0
        private static void EventReport(EventBasedReport eventBasedReport)
        {
            eventBasedReport.OnReportBuilt += PrintReportResult;
            eventBasedReport.OnReportBuilt += SendReportResult;
            eventBasedReport.StartBuilding();

            //eventBasedReport.OnReportBuilt -= SendReportResult;
        }
Exemple #4
0
        private static void AnonymousEventReport(EventBasedReport eventBasedReport)
        {
            eventBasedReport.OnReportBuilt += delegate(string result)
            {
                Console.WriteLine($"Anonymous report result: {result}");
            };
            eventBasedReport.OnReportBuilt += PrintReportResult;
            eventBasedReport.OnReportBuilt += SendReportResult;

            eventBasedReport.StartBuilding();
        }