Exemplo n.º 1
0
        /// <summary>
        /// Combines two events to a single event which is triggered whenever one of the original events is triggered.
        /// </summary>
        /// <param name="e1">an event</param>
        /// <param name="e2">another event</param>
        /// <returns>combined event</returns>
        public static MultiEvent operator |(EventSource e1, EventSource e2)
        {
            List <EventSource> all = new List <EventSource>();

            MultiEvent m1 = e1 as MultiEvent;
            MultiEvent m2 = e2 as MultiEvent;

            if (m1 != null)
            {
                all.AddRange(m1._events);
            }
            else
            {
                all.Add(e1);
            }

            if (m2 != null)
            {
                all.AddRange(m2._events);
            }
            else
            {
                all.Add(e2);
            }

            return(new MultiEvent(null, all));
        }
Exemplo n.º 2
0
 /// <summary>
 /// This is the wrapper function which gets actually scheduled for a threaded process.
 /// </summary>
 private async void TopLevelWrapperTriggered()
 {
     try
     {
         while (true)
         {
             Context.CurrentProcess = this;
             InitialAction();
             var   me = new MultiEvent(null, Sensitivity);
             await me; //await Sensitivity; would be "nicer", but does not compile even though an awaitable ExtensionMethod is declared for an Array of AbstractEvents
         }
     }
     catch (StopThreadException)
     {
     }
 }
Exemplo n.º 3
0
 public Awaiter(MultiEvent evt)
 {
     _event = evt;
 }