public async Task <bool> CheckIsStillLockedAsync(DistributedLockSettings settings) { Check.NotNull(settings, nameof(settings)); if (settings is NullLockSettings) { return(await NullLockManager.CheckIsStillLockedAsync(settings).ConfigureAwait(false)); } try { using var scope = _serviceScopeFactory.CreateScope(); return(await CheckIsStillLockedAsync( settings.ResourceName, settings.UniqueId, settings.HeartbeatTimeout, scope.ServiceProvider) .ConfigureAwait(false)); } catch (Exception ex) { _logger.LogFailedToCheckLock(settings, ex); return(false); } }
public async Task <bool> CheckIsStillLockedAsync(DistributedLockSettings settings) { Check.NotNull(settings, nameof(settings)); if (settings is NullLockSettings) { return(await NullLockManager.CheckIsStillLockedAsync(settings).ConfigureAwait(false)); } try { using var scope = _serviceScopeFactory.CreateScope(); return(await CheckIsStillLockedAsync( settings.ResourceName, settings.UniqueId, settings.HeartbeatTimeout, scope.ServiceProvider) .ConfigureAwait(false)); } catch (Exception ex) { _logger.LogError( CoreEventIds.FailedToCheckDistributedLock, ex, "Failed to check lock {lockName} ({lockUniqueId}). See inner exception for details.", settings.ResourceName, settings.UniqueId); return(false); } }
private async Task CheckIsStillLockedAsync() { if (Status != DistributedLockStatus.Acquired) { return; } if (!await _lockManager.CheckIsStillLockedAsync(_settings).ConfigureAwait(false)) { Status = DistributedLockStatus.Lost; } }