Exemple #1
0
        public void Wait()
        {
            this.waiting = true;
            TimeSpan timeSpan = TimeSpan.FromMilliseconds(this.Timeout);

            while (!this.doneWaiting && (this.Timeout < 0 || (DateTime.Now - this.StartTime) < timeSpan))
            {
                ;
            }

            GenericAction.RemoveGenericEventHandler(this.Subject, this.EventInfo, this.CallbackWrap);
        }
Exemple #2
0
        public EventHook(object subject, EventInfo eventInfo, Action <object[], Info> callback = null, int timeout = TO.Infinite)
        {
            if (eventInfo == null)
            {
                throw new ArgumentNullException("eventInfo");
            }

            this.Subject   = subject;
            this.EventInfo = eventInfo;
            this.Callback  = callback;
            this.Timeout   = timeout;
            this.ResetStartTime();
            GenericAction.AddGenericEventHandler(subject, eventInfo, this.CallbackWrap);
        }
        private UniversalEventHandle(object source, EventInfo eventInfo, UniversalEventCallback callback)
        {
            if (eventInfo == null)
            {
                throw new ArgumentNullException("eventInfo");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            this.UniversalEventType = UniversalEventType.Event;
            this.EventInfo          = eventInfo;
            GenericAction.AddGenericEventHandler(source, eventInfo, this.OnEventChanged);
            this.Callback = callback;

            this.hashCode = HashCodeOperations.Combine(source ?? 0, eventInfo, callback);
        }
 public override void RemoveEventHandler()
 {
     GenericAction.RemoveGenericEventHandler(this.Subject, this.EventInfo, this.OnEvent);
 }
            public override bool AddEventHandler()
            {
                GenericAction.AddGenericEventHandler(this.Subject, this.EventInfo, this.OnEvent);

                return(true);
            }