public static void RaiseEvent(this EventMarshalDel @event, IMyEventActions sender, MyEventArgs e)
 {
     if (@event != null)
     {
         @event(sender, e);
     }
 }
示例#2
0
 /// <summary>
 /// The Event Marshal.
 /// </summary>
 public void EventMarshal(IMyEventActions sender, MyEventArgs e)
 {
     if (sender.Event.InvokeRequired)
     {
         //Without the lock in Fire() a race condition would occurr here when one
         //thread closes the MyEvent form and another tries to Invoke it here
         sender.Event.BeginInvoke(
             new OnSomethingHappenedDel(sender.OnSomethingHappened),
             new object[] { e });
     }
     else
     {
         sender.OnSomethingHappened(e);
     }
     Recurse(e);
 }
示例#3
0
        /// <summary>
        /// The Event Marshal.
        /// </summary>
        public void EventMarshal(IMyEventActions sender, MyEventArgs e)
        {
            if (null != sender)
            {
                if (sender.Event.InvokeRequired)
                {
                    sender.Event.BeginInvoke(
                        new OnSomethingHappenedDel(sender.OnSomethingHappened),
                        new object[] { e });
                }
                else
                {
                    sender.OnSomethingHappened(e);
                }
            }

            //If you require recursion, you need to do this...
            Recurse(e);
        }
示例#4
0
        /// <summary>
        /// The event result arbiter.
        /// </summary>
        private static void OnSomethingHappened(object sender, MyEventArgs e)
        {
            IMyEventActions EventActions = sender as IMyEventActions;

            if (null != EventActions)
            {
                switch ((MyEventArgs.Funcs)e.Function)
                {
                case MyEventArgs.Funcs.Shutdown:
                    EventActions.Shutdown(e);
                    break;

                case MyEventArgs.Funcs.SomeOtherEvent:
                    EventActions.SomeOtherEvent(e);
                    break;

                case MyEventArgs.Funcs.TheLastEvent:
                    EventActions.TheLastEvent(e);
                    break;
                }
            }
        }