Callbacks With Interfaces Or Delegates
I'll start like this by directly jumping into a scenario. You have this one class, which has many methods called by different other classes. For the moment let's not think about those many methods and who calls those. Focusing on the the matter in hand the requirement is such, that you have to call a method in some other class, which will consume some time for execution. So that method runs that execution in a background thread inside, and only he knows when it finishes. In this scenario you have to give them something to call, may be some reference or some callback method, after the execution of the background thread is done. What I'm going to discuss now is the ways to do it. Delegates First I'll take you on the C#.NET road. In C# there is a very simple and straight forward way to do this, thanks to " Delegates ", which are reference points to the methods. In simple words, in a delegate you can put a method in there,...