private void ResultsReturned(IAsyncResult iar) { DelegateReturnInt subDelegate = (DelegateReturnInt)iar.AsyncState; int result = subDelegate.EndInvoke(iar); Console.WriteLine("result = {0}", result); }
// Use this for initialization void Start() { e = new Event(); eS = new EventString(); e.Listen(NormalEvent); eS.Listen(StringEvent); //Events need function call to invoke e.Trigger(); eS.Trigger("EVENT RIGGERED!"); //Delegates del += NormalEvent; delString += StringEvent; delReturnInt += EventReturnValue; //Delegates can directly call itself as a function for invocation del(); delString("DELEGATE TRIGGERED!"); Debug.Log("EVENT RETURN VALUE " + delReturnInt()); action += NormalEvent; actionString += StringEvent; //Action can directly call itself as a function for invocation action(); actionString("ACTION TRIGGERED!"); }
private static int getSelectedIndex() { if (boxDevice.InvokeRequired) { DelegateReturnInt d = new DelegateReturnInt(getSelectedIndex); return((int)configureInputForm.Invoke(d, new object[] {})); } else { return(boxDevice.SelectedIndex); } }