Happiness in the Universe

Peter, his boss, and the universe were finally satisfied. Peter's boss and the universe were allowed to be notified of the events that interested them, reducing the burden of implementation and the cost of unnecessary round-trips. Peter could notify each of them, ignoring how long it took them to return from their target methods while still getting his results asynchronously. The result was the following complete solution:

 delegate void WorkStarted(); delegate void WorkProgressing(); delegate int WorkCompleted(); class Worker { public void DoWork() { Console.WriteLine("Worker: work started"); if( started != null ) started(); Console.WriteLine("Worker: work progressing"); if( progressing != null ) progressing(); Console.WriteLine("Worker: ...

Get Windows Forms Programming in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.