public void SomeMethod(SomeMethodDelegate someMethodDelegate) { int a = 0; for (int i = 0; i < 10; i++) { someMethodDelegate(i); a = a + i; Thread.Sleep(1000); } }
private void ExecuteThroughDeclaredDelegates() { Print("Executing through declared delegates..."); var someMethod = new SomeMethodDelegate(SomeMethod); someMethod.Invoke(); var someOtherMethod = new SomeOtherMethodDelegate(SomeOtherMethod); var s = someOtherMethod.Invoke(200); Print("ExecuteThroughDeclaredDelegates() SomeOtherMethod() returned " + s); }