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