Craig100
02/07/2025, 6:02 PMPeriod = TimeSpan.FromMinutes(GetTime());private event EventHandler? _periodChanged;
    public event EventHandler PeriodChanged
    {
        add { _periodChanged += value; }
        remove { _periodChanged -= value; }
    }valueAmbert
02/08/2025, 2:00 PMhealthChecksSettings.OnChange(x =>
        {
            Period = x.Notification.Period;
            _periodChanged?.Invoke(this, EventArgs.Empty);
        });Craig100
02/08/2025, 4:24 PMAmbert
02/09/2025, 3:50 PMAmbert
02/09/2025, 3:50 PMCraig100
02/10/2025, 9:31 AMCraig100
02/10/2025, 1:40 PMprivate int GetTime() {
        using var context = _contextFactory.EnsureUmbracoContext();
        if (context.UmbracoContext.Content == null) {
            throw new InvalidOperationException("Application can't access nucache...");
        }
        var siteSettings = context.UmbracoContext.Content.GetAtRoot().First().FirstChild<SiteSettings>();
        int scheduledTimePeriod = siteSettings?.PDfclearanceSchedule ?? 3;
           
        return scheduledTimePeriod;
    }Kevin Jump
02/10/2025, 2:37 PMRecurringHostedBaseChangePeriodcs
internal class ProcessingQueueBackgroundHostedService
    : RecurringHostedServiceBase
{
....cs
   private void SetPeriod(TimeSpan period, bool addBuffer)
   {
       _currentPeriod = period + (addBuffer ? TimeSpan.FromSeconds(1) : TimeSpan.Zero);
       _logger.LogDebug("Setting period to {time} seconds", _currentPeriod.TotalSeconds);
       ChangePeriod(_currentPeriod);
   }Kevin Jump
02/10/2025, 2:41 PMKevin Jump
02/10/2025, 2:43 PMcs
_backgroundTaskQueue.QueueBackgroundWorkItem(
    cancellationToken => Task.Run(() =>
    {    _backgroundService.ProcessQueueItem(notification.QueuedItem.Key);
    }, cancellationToken));Kevin Jump
02/10/2025, 2:44 PMcs
 if (await _processingSemaphore.WaitAsync(TimeSpan.FromMinutes(_waitTime)))
 {
     try
     {
         // do the things you need here.
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error")
     }
     finally
     {
         _processingSemaphore.Release();
     }
 }Kevin Jump
02/10/2025, 2:46 PMbackgroundHostedServicebackgroundServiceCraig100
02/10/2025, 4:23 PMinternal class ProcessingQueueBackgroundHostedService
    : RecurringHostedServiceBaseKevin Jump
02/10/2025, 4:44 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by