public void Run() { for (;;) { //spava pola sekunde Thread.Sleep(500); if (theDelegate != null) { //eksplicitno poziva svaku delegiranu metodu foreach (DelegateThatReturnsInt del in theDelegate.GetInvocationList()) { //poziva asinhrono i prosljedjuje delegat kao objekat stanja del.BeginInvoke(new AsyncCallback(ResultsReturned), del); } } } }
public void Run() { for (;;) { //spava pola sekunde Thread.Sleep(500); if (theDelegate != null) { //eksplicitno poziva svaku delegiranu metodu foreach (DelegateThatReturnsInt del in theDelegate.GetInvocationList()) { int result = del(); Console.WriteLine("Delegates fired! Return result: {0}", result); } Console.WriteLine(); } } }
public void Run() { for (;;) { Thread.Sleep(500); if (TheDelegate == null) { continue; } foreach (var @delegate in TheDelegate.GetInvocationList()) { var del = (DelegateThatReturnsInt)@delegate; del.BeginInvoke( ResultsReturned, del); } } // ReSharper disable once FunctionNeverReturns }
public void Run() { for ( ; ;) { // sleep for a half second Thread.Sleep(500); if (theDelegate != null) { // explicitly invoke each delegated method foreach ( DelegateThatReturnsInt del in theDelegate.GetInvocationList()) { int result = del(); Console.WriteLine( "Delegates fired! Returned result: {0}", result); } // end foreach Console.WriteLine(); } // end if } // end for ;; } // end run