Example #1
0
        public static Polyface IsBackground(this Polyface root, bool isEnabled, double backgroundIntervalMSecs, ILogic backgroundAction)
        {
            Condition.Requires(root).IsNotNull();
            var bg = BackgroundHost.New(isEnabled, backgroundIntervalMSecs, backgroundAction);

            root.Is(bg);
            return(root);
        }
Example #2
0
        public static Polyface IsEmptyBackground(this Polyface root)
        {
            Condition.Requires(root).IsNotNull();
            var bg = BackgroundHost.NewBlank();

            root.Is(bg);
            return(root);
        }
 public void ClearBackgroundAction()
 {
     //clear the old task
     if (this.BackgroundHost != null)
     {
         this.BackgroundHost.Dispose();
         this.BackgroundHost = null;
     }
 }
 public void ClearBackgroundAction()
 {
     //clear the old task
     if (this.BackgroundHost != null)
     {
         this.BackgroundHost.Dispose();
         this.BackgroundHost = null;
     }
 }
Example #5
0
        public IPollingDecoration SetBackgroundAction(ILogicOf<ITask> backgroundAction, double backgroundIntervalMSecs = 30000)
        {
            this.ClearBackgroundAction();
            backgroundAction.Context = (this as ITask);

            this.Background = new BackgroundHost(true, backgroundIntervalMSecs, backgroundAction);

            return this;
        }
        /// <summary>
        /// set background action 
        /// </summary>
        public void SetBackgroundAction(LogicOf<ICondition> backgroundAction,
            double backgroundIntervalMSecs = 30000)
        {
            this.BackgroundStrategy = backgroundAction;

            lock (this._stateLock)
            {
                //clear the old task
                if (this.BackgroundHost != null)
                {
                    this.BackgroundHost.Dispose();
                    this.BackgroundHost = null;
                }

                backgroundAction.Context = this as ICondition;

                this.BackgroundHost = new BackgroundHost(true, backgroundIntervalMSecs,
                    backgroundAction);
            }
        }
        /// <summary>
        /// set background action
        /// </summary>
        public void SetBackgroundAction(LogicOf <ICondition> backgroundAction,
                                        double backgroundIntervalMSecs = 30000)
        {
            this.BackgroundStrategy = backgroundAction;

            lock (this._stateLock)
            {
                //clear the old task
                if (this.BackgroundHost != null)
                {
                    this.BackgroundHost.Dispose();
                    this.BackgroundHost = null;
                }

                backgroundAction.Context = this as ICondition;

                this.BackgroundHost = new BackgroundHost(true, backgroundIntervalMSecs,
                                                         backgroundAction);
            }
        }
Example #8
0
        public ConditionalWaiter(ICondition condition, ICondition stopWaitingCondition = null) : base()
        {
            CuttingEdge.Conditions.Condition.Requires(condition).IsNotNull();
            this.Condition = condition;
            this.StopWaitingCondition = stopWaitingCondition;

            this._background = new BackgroundHost(true, 1000,
                Logic.New(() =>
                {
                    lock (_stateLock)
                    {
                        if (Condition.Evaluate().GetValueOrDefault())
                        {
                            this._isResolved = true;
                            Monitor.Pulse(_stateLock);
                        }
                        else if (this.StopWaitingCondition != null && this.StopWaitingCondition.Evaluate().GetValueOrDefault() == true)
                        {
                            this._isResolved = false;
                            Monitor.Pulse(_stateLock);
                        }
                    }
                }));
        }