コード例 #1
0
        /// <inheritdoc />
        protected override async Task <BoolResult> StartupCoreAsync(OperationContext context)
        {
            // Splitting initialization into two pieces:
            // Normal startup procedure and post-initialization step that notifies all
            // the special stores that the initialization has finished.
            // This is a workaround to make sure hibernated sessions are fully restored
            // before FileSystemContentStore can evict the content.
            var result = await tryStartupCoreAsync();

            if (!result)
            {
                // We should not be running post initialization operation if the startup operation failed.
                return(result);
            }

            foreach (var store in StoresByName.Values)
            {
                if (store is IContentStore contentStore)
                {
                    contentStore.PostInitializationCompleted(context, result);
                }
            }

            return(result);

            async Task <BoolResult> tryStartupCoreAsync()
            {
                try
                {
                    if (!FileSystem.DirectoryExists(Config.DataRootPath))
                    {
                        FileSystem.CreateDirectory(Config.DataRootPath);
                    }

                    await StartupStoresAsync(context).ThrowIfFailure();

                    await LoadHibernatedSessionsAsync(context);

                    InitializeAndStartGrpcServer(Config.GrpcPort, BindServices(), Config.RequestCallTokensPerCompletionQueue, Config.GrpcThreadPoolSize ?? DefaultGrpcThreadPoolSize);

                    _serviceReadinessChecker.Ready(context);

                    _sessionExpirationCheckTimer = new IntervalTimer(
                        () => CheckForExpiredSessionsAsync(context),
                        MinTimeSpan(Config.UnusedSessionHeartbeatTimeout, TimeSpan.FromMinutes(CheckForExpiredSessionsPeriodMinutes)),
                        message => Tracer.Debug(context, $"[{CheckForExpiredSessionsName}] message"));

                    _logIncrementalStatsTimer = new IntervalTimer(
                        () => LogIncrementalStatsAsync(context),
                        Config.LogIncrementalStatsInterval);

                    _logMachineStatsTimer = new IntervalTimer(
                        () => LogMachinePerformanceStatistics(context),
                        Config.LogMachineStatsInterval);

                    return(BoolResult.Success);
                }
                catch (Exception e)
                {
                    return(new BoolResult(e));
                }
            }
        }
コード例 #2
0
        public DeluxeTimerWidget(string name, int row, int column) : base("Timer", name, row, column)
        {
            timerIndex = 0;

            SetSizeRequest(310, 169);

            timers = new IntervalTimer[3];
            for (int i = 0; i < timers.Length; ++i)
            {
                timers[i] = IntervalTimer.GetTimer("Timer " + name + " " + (i + 1).ToString());
                timers[i].TimerInterumEvent += OnTimerInterum;
                timers[i].TimerElapsedEvent += OnTimerElapsed;
                timers[i].TimerStartEvent   += OnTimerStartStop;
                timers[i].TimerStopEvent    += OnTimerStartStop;
            }

            var box2 = new TimerBackground(310, 139);

            box2.color        = "grey4";
            box2.transparency = 0.1f;
            Put(box2, 0, 30);

            tabs = new TimerTab[3];
            for (int i = 2; i >= 0; --i)
            {
                tabs[i]      = new TimerTab(i);
                tabs[i].text = "Timer " + (i + 1).ToString();
                tabs[i].ButtonReleaseEvent += OnTabButtonRelease;
                Put(tabs[i], 90 * i, 0);
                tabs[i].Show();
            }

            tabs[0].selected = true;

            var minuteLabel = new TouchLabel();

            minuteLabel.text      = "Minutes";
            minuteLabel.textColor = "grey3";
            Put(minuteLabel, 5, 37);
            minuteLabel.Show();

            minutes = new TouchTextBox();
            minutes.SetSizeRequest(99, 51);
            minutes.enableTouch       = true;
            minutes.textSize          = 16;
            minutes.textAlignment     = TouchAlignment.Center;
            minutes.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(minutes, 3, 57);

            minUpDown = new TouchUpDownButtons();
            minUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = (Convert.ToUInt32(minutes.text) + 1) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                }
            };
            minUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    if (minutes.text != "0")
                    {
                        uint time = (Convert.ToUInt32(minutes.text) - 1) * 60;
                        time += Convert.ToUInt32(seconds.text);
                        UpdateTime(time);
                    }
                }
            };
            Put(minUpDown, 3, 113);
            minUpDown.Show();

            var secondsLabel = new TouchLabel();

            secondsLabel.text      = "Seconds";
            secondsLabel.textColor = "grey3";
            Put(secondsLabel, 108, 37);
            secondsLabel.Show();

            seconds = new TouchTextBox();
            seconds.SetSizeRequest(98, 51);
            seconds.enableTouch       = true;
            seconds.textAlignment     = TouchAlignment.Center;
            seconds.textSize          = 16;
            seconds.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text);

                    if (time < 60)
                    {
                        time += Convert.ToUInt32(minutes.text) * 60;
                    }

                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(seconds, 106, 57);

            secUpDown = new TouchUpDownButtons();
            secUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    ++time;
                    UpdateTime(time);
                }
            };
            secUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    if (time != 0)
                    {
                        --time;
                        UpdateTime(time);
                    }
                }
            };
            Put(secUpDown, 106, 113);
            secUpDown.Show();

            startStopButton = new TouchButton();
            startStopButton.SetSizeRequest(98, 51);
            startStopButton.ButtonReleaseEvent += OnStartStopButtonRelease;
            Put(startStopButton, 209, 57);
            startStopButton.Show();

            resetButton = new TouchButton();
            resetButton.SetSizeRequest(98, 51);
            resetButton.text = "Reset";
            resetButton.ButtonReleaseEvent += OnResetButtonRelease;
            Put(resetButton, 209, 113);
            resetButton.Show();

            if (timers[timerIndex].enabled)
            {
                UpdateTime(timers[timerIndex].secondsRemaining, false);
            }
            else
            {
                UpdateTime(timers[timerIndex].totalSeconds, false);
            }
        }
コード例 #3
0
 protected AmmoHandlerState(ActiveModule module) : base(module, ModuleStateType.AmmoLoad)
 {
     Debug.Assert(module.ParentRobot != null, "module.ParentRobot != null");
     _timer = new IntervalTimer(module.ParentRobot.AmmoReloadTime);
 }
コード例 #4
0
 public ShutdownState(ActiveModule module, IntervalTimer timer) : base(module, ModuleStateType.Shutdown)
 {
     _timer = timer;
 }
コード例 #5
0
ファイル: TripViewControl.cs プロジェクト: Arreba/TZDriver
 public TripViewControl()
 {
     DefaultStyleKey = typeof(TripViewControl);
     smartTimer      = new IntervalTimer(15);
 }
コード例 #6
0
 public Effect()
 {
     Timer           = null;
     EnableModifiers = true;
 }
コード例 #7
0
 public ExpirationTimer(float time, ITimeGetter timeGetter = null)
 {
     _intervalTimer              = new IntervalTimer(time, false, timeGetter);
     _intervalTimer.OnTickTimer += TimerTick;
 }
コード例 #8
0
 public ModuleActivator(ActiveModule module)
 {
     _module = module;
     _timer  = new IntervalTimer(TimeSpan.FromSeconds(1), true);
 }
コード例 #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            setContext.Load();
            // Звук
            if (setContext.Settings.ListSound != null)
            {
                cbFileName.Items.Clear();
                foreach (var sound in setContext.Settings.ListSound)
                {
                    var fullfilename = sound;
                    var filename     = fullfilename.Split('\\').Last();
                    cbFileName.Items.Add(filename);
                }
            }

            cbFileName.SelectedIndex = setContext.Settings.CurrentSound;
            //Переходной таймер
            cbTransit.Checked = setContext.Settings.IsTransitTimer;

            var tempTransitTimer   = setContext.Settings.TransitTimer;
            var hour_timer_transit = (tempTransitTimer.Hour.ToString().Length == 1)
                ? $"0{tempTransitTimer.Hour}"
                : tempTransitTimer.Hour.ToString();
            var min_timer_transit = (tempTransitTimer.Min.ToString().Length == 1)
                ? $"0{tempTransitTimer.Min}"
                : tempTransitTimer.Min.ToString();
            var sec_timer_transit = (tempTransitTimer.Sec.ToString().Length == 1)
                ? $"0{tempTransitTimer.Sec}"
                : tempTransitTimer.Sec.ToString();

            mtbTransitTimer.Text = $"{hour_timer_transit}" +
                                   $":{min_timer_transit}" +
                                   $":{sec_timer_transit}";
            //Таймеры

            if (setContext.Settings.ListTimers != null &&
                setContext.Settings.ListTimers.Count != 0)
            {
                var tempTimer = setContext.Settings.ListTimers[0];
                var hourTimer = (tempTimer.Hour.ToString().Length == 1)
                    ? $"0{tempTimer.Hour}"
                    : tempTimer.Hour.ToString();
                var minTimer = (tempTimer.Min.ToString().Length == 1)
                    ? $"0{tempTimer.Min}"
                    : tempTimer.Min.ToString();
                var secTimer = (tempTimer.Sec.ToString().Length == 1)
                    ? $"0{tempTimer.Sec}"
                    : tempTimer.Sec.ToString();
                mtbTimer.Text        = $"{hourTimer}:{minTimer}:{secTimer}";
                nudCountTimers.Value = setContext.Settings.ListTimers.Count;

                //Добавление таймеров
            }
            _intervalTimerList = new IntervalTimer(setContext.Settings.ListTimers,
                                                   setContext.Settings.IsTransitTimer, setContext.Settings.TransitTimer);
            _intervalTimerList.OnIntervalTimersIsDone += (o, args) =>
            {
                StopTimers();
            };
            _intervalTimerList.OnCurrentTimerIsDone += (o, args) =>
            {
                var showForm = new Task(() =>
                {
                    using (var notificationForm = new NotificationForm())
                        notificationForm.ShowDialog();
                });
                showForm.Start();
            };

            lCountTimers.Text = $"1/{_intervalTimerList.MaxCount}";
        }