示例#1
0
        public static TimedComponent Create(FbEventArgs i_Args, FacebookAppEngine i_Engine, eTasksType i_ChosenTask)
        {
            TimedComponent timedComponent = new TimedComponent {
                FbEventArgs = i_Args, ActionObject = FbActionFactory.Create(i_Engine, i_ChosenTask), Timer = new System.Timers.Timer(), Invoked = false
            };

            timedComponent.ActionObject.LoadAction();
            timedComponent.Timer.Enabled  = false;
            timedComponent.Timer.Elapsed += new System.Timers.ElapsedEventHandler(timedComponent.OnElapsed);

            if ((timedComponent.FbEventArgs.Time - DateTime.Now).TotalMilliseconds > 0)
            {
                timedComponent.Timer.Interval = (timedComponent.FbEventArgs.Time - DateTime.Now).TotalMilliseconds;
            }
            else
            {
                // if the time already passed, we commit the action immediately
                timedComponent.Timer.Interval = 0.1;
            }

            return(timedComponent);
        }
 public TimedComponent CreateTimedComponent(FbEventArgs args, eTasksType taskType)
 {
     return(TimedComponent.Create(args, this, taskType));
 }