示例#1
0
文件: Watch.cs 项目: flippynips/EFZ
        public Watch(long milliseconds, bool repeat, IAction onDone, bool run = true, Needle needle = null)
        {
            _time    = CurrentTime = milliseconds;
            Repeat   = repeat;
            OnDone   = onDone;
            _updater = new ActionAct(Update);
            _running = run;

            // was the needle specified?
            if (needle == null)
            {
                // no, derive the correct needle
                _needle = _time % 1000 == 0 ?
                          ManagerUpdate.Iterant :
                          ManagerUpdate.Polling;
            }
            else
            {
                // yes, persist the needle
                _needleSpecified = true;
                _needle          = needle;
            }

            if (_running && _time > 0)
            {
                _needle.AddUpdate(_updater);
            }
        }