private void ResultsReturned(IAsyncResult iar)
        {
            DelegateReturnInt subDelegate = (DelegateReturnInt)iar.AsyncState;
            int result = subDelegate.EndInvoke(iar);

            Console.WriteLine("result = {0}", result);
        }
예제 #2
0
    // 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!");
    }
예제 #3
0
 private static int getSelectedIndex()
 {
     if (boxDevice.InvokeRequired)
     {
         DelegateReturnInt d = new DelegateReturnInt(getSelectedIndex);
         return((int)configureInputForm.Invoke(d, new object[] {}));
     }
     else
     {
         return(boxDevice.SelectedIndex);
     }
 }