Exemple #1
0
 public static Original::Timer ___ctor_newobj(Original::TimerCallback tc, object state, uint dueTime, uint period)
 {
     return(Helper.SimpleWrap <Original::Timer>(
                delegate(ClrSyncManager manager) { return TimerHelpers.CreateTimer(manager, tc, state, new TimeSpan(dueTime), new TimeSpan(period)); },
                delegate() { return new Original::Timer(tc, state, dueTime, period); }
                ));
 }
Exemple #2
0
        /* Use a TimerCallback delegate to specify the method you want the Timer to execute.
         * The timer delegate is specified when the timer is constructed, and cannot be changed.
         * The method does not execute on the thread that created the timer; it executes on a ThreadPool
         * thread supplied by the system.
         *
         * When you create a timer, you can specify an amount of time to wait before the first execution
         * of the method (due time), and an amount of time to wait between subsequent executions (period).
         * You can change these values, or disable the timer, using the Change method.
         *
         * Note: As long as you are using a Timer, you must keep a reference to it. As with any managed object,
         * a Timer is subject to garbage collection when there are no references to it. The fact that a Timer is
         * still active does not prevent it from being collected.
         *
         * When a timer is no longer needed, use the Dispose method to free the resources held by the timer. To
         * receive a signal when the timer is disposed, use the Dispose(WaitHandle) method overload that takes a
         * WaitHandle. The WaitHandle is signaled when the timer has been disposed.
         *
         * The callback method executed by the timer should be reentrant, because it is called on ThreadPool threads.
         * The callback can be executed simultaneously on two thread pool threads if the timer interval is less than
         * the time required to execute the callback, or if all thread pool threads are in use and the callback is
         * queued multiple times.
         *
         * Note: System.Threading.Timer is a simple, lightweight timer that uses callback methods and is served by
         * threadpool threads. You might also consider System.Windows.Forms.Timer for use with Windows forms, and
         * System.Timers.Timer for server-based timer functionality. These timers use events and have additional features.
         */

        public static Original::Timer ___ctor_newobj(Original::TimerCallback tc)
        {
            return(Helper.SimpleWrap <Original::Timer>(
                       delegate(ClrSyncManager manager) { return TimerHelpers.CreateTimer(manager, tc, null, new TimeSpan(Timeout.Infinite),
                                                                                          new TimeSpan(Timeout.Infinite)); },
                       delegate() { return new Original::Timer(tc); }
                       ));
        }
Exemple #3
0
 public VoiceChannelTrackerService(DiscordSocketClient discord, VoiceChannelTrackerSettings settings, ILogger <VoiceChannelTrackerService> logger)
     : base(discord)
 {
     _logger  = logger;
     _discord = discord;
     _discord.GuildAvailable += InitailizeVoiceChannelTracker;
     _settings = settings;
     _clearOldMessagesInterval = TimerHelpers.SetTimeout(async() => { await DeleteOldMessages(); }, 120000, true);
 }
        private async Task InitializeAsync()
        {
            _timer?.Stop();
            _timer?.Dispose();
            _timer = await TimerHelpers.SetTimeoutAsync(HandleCheckIntervalElapsedAsync, 10000, true, true);

            _discord.MessageReceived -= HandleMessageReceived;
            _discord.MessageReceived += HandleMessageReceived;
        }
Exemple #5
0
        private async Task StartNewBet(string maxValue)
        {
            if (!int.TryParse(maxValue, out var maxRollValue))
            {
                return;
            }

            _currentRound = GamblingRound.CreateInstance(maxRollValue);
            await _gamblingChannel.SendMessageAsync($"New bet (Max roll value: {maxRollValue}) started. Type `!jb` to join this round. Starting in 15 seconds.");

            _awaitingRollsTimer = TimerHelpers.SetTimeout(async() => { await StartAwaitingRolls(); }, 15000);
            _rollRemindTimer    = TimerHelpers.SetTimeout(async() => { await RemindRollers(); }, 30000);
            _roundTimeoutTimer  = TimerHelpers.SetTimeout(async() => { await EndRound(); }, 45000);
        }
Exemple #6
0
 public static Original::Timer ___ctor_newobj(Original::TimerCallback tc, object state, TimeSpan dueTime, TimeSpan period)
 {
     if (dueTime.TotalMilliseconds < 0 && dueTime.TotalMilliseconds != Timeout.Infinite)
     {
         throw new ArgumentOutOfRangeException();
     }
     if (period.TotalMilliseconds < 0 && period.TotalMilliseconds != Timeout.Infinite)
     {
         throw new ArgumentOutOfRangeException();
     }
     return(Helper.SimpleWrap <Original::Timer>(
                delegate(ClrSyncManager manager) { return TimerHelpers.CreateTimer(manager, tc, state, dueTime, period); },
                delegate() { return new Original::Timer(tc, state, dueTime, period); }
                ));
 }
Exemple #7
0
        private async Task InitializeRefreshCheckerAsync()
        {
            _refreshInterval = await TimerHelpers.SetTimeoutAsync(async() =>
            {
                var previousLastRefresh = _lastEventUpdate;
                var events = await GetEventsAsync();

                if (previousLastRefresh < _lastEventUpdate)
                {
                    _refreshInterval.Stop();
                    _runningRefresh = false;
                    await UpdateExistingEventEmbedAsync(events);
                }
            }, 10000, true);
        }
        private async Task Start()
        {
            await TimerHelpers.SetTimeoutAsync(async() =>
            {
                var sw = new Stopwatch();
                sw.Start();
                _logger.LogInformation("Getting applications.");
                var applications = await _neonApiService.GetApplicationListAsync();

                if (applications != null)
                {
                    _logger.LogInformation($"Getting {applications.Count()} applications took {sw.ElapsedMilliseconds} ms.");
                    await CheckForNewApplications(applications);
                    await CheckForOverdueApplications(applications);
                }
            }, 60000 * 2, true, true);

            _discord.MessageReceived -= HandleMessage;
            _discord.MessageReceived += HandleMessage;
        }
Exemple #9
0
 private async Task StartCheckingForChangesAsync()
 {
     _interval = await TimerHelpers.SetTimeoutAsync(CheckForChangeAsync, _settings.CheckInterval, true, true);
 }
Exemple #10
0
 private async Task InitializeServiceAsync()
 {
     _checkInterval = await TimerHelpers.SetTimeoutAsync(async() => { await CheckForNewMessagesAsync(); }, 60 * 1000 * 3, true, true);
 }
Exemple #11
0
 private async Task InitializeServiceAsync()
 {
     _checkInterval?.Stop();
     _checkInterval?.Dispose();
     _checkInterval = await TimerHelpers.SetTimeoutAsync(async() => { await CheckForNewTweetsAsync(); }, _settings.CheckIntervalSeconds * 1000, true, true);
 }