public void Subscribe(ClassWithReturnIntDelegate theClass)
 {
     theClass.returnIntDelegate += delegate {
         Thread.Sleep(1000);
         return(++myCounter);
     };
 }
        static void RunDelegateReturnInt()
        {
            ClassWithReturnIntDelegate tmpClass = new ClassWithReturnIntDelegate();

            ClassWithReturnIntDelegate.FirstSubscriber fst = new ClassWithReturnIntDelegate.FirstSubscriber();
            fst.Subscribe(tmpClass);
            ClassWithReturnIntDelegate.SecondSubscriber scd = new ClassWithReturnIntDelegate.SecondSubscriber();
            scd.Subscribe(tmpClass);
            int result = tmpClass.returnIntDelegate();

            Console.WriteLine("result = {0}", result);
            result = tmpClass.returnIntDelegate();
            Console.WriteLine("result = {0}", result);
            result = tmpClass.returnIntDelegate();
            Console.WriteLine("result = {0}", result);

            tmpClass.Run();
        }
 public void Subscribe(ClassWithReturnIntDelegate theClass)
 {
     theClass.returnIntDelegate += delegate {
         return(myCounter += 2);
     };
 }