Preventing usage disposed object and fixed EnsureLifetimeScope.

This commit is contained in:
Sipke Schoorstra
2015-08-10 15:27:15 +01:00
parent 16cd4e89c4
commit 68c401c6eb

View File

@@ -35,6 +35,9 @@ namespace Orchard.TaskLease.Services {
public ILogger Logger { get; set; }
public bool TryAcquire(string name, TimeSpan maxLifetime) {
if(_isDisposed)
throw new ObjectDisposedException("DatabaseLock");
Argument.ThrowIfNullOrEmpty(name, "name");
if (name.Length > 256)
@@ -110,7 +113,7 @@ namespace Orchard.TaskLease.Services {
}
private ILifetimeScope EnsureLifetimeScope(string name) {
return _scope = _lifetimeScope.BeginLifetimeScope("Orchard.Tasks.Locking.Database." + name);
return _scope ?? (_scope = _lifetimeScope.BeginLifetimeScope("Orchard.Tasks.Locking.Database." + name));
}
private void DisposeLifetimeScope() {