mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Preventing usage disposed object and fixed EnsureLifetimeScope.
This commit is contained in:
@@ -35,6 +35,9 @@ namespace Orchard.TaskLease.Services {
|
|||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public bool TryAcquire(string name, TimeSpan maxLifetime) {
|
public bool TryAcquire(string name, TimeSpan maxLifetime) {
|
||||||
|
if(_isDisposed)
|
||||||
|
throw new ObjectDisposedException("DatabaseLock");
|
||||||
|
|
||||||
Argument.ThrowIfNullOrEmpty(name, "name");
|
Argument.ThrowIfNullOrEmpty(name, "name");
|
||||||
|
|
||||||
if (name.Length > 256)
|
if (name.Length > 256)
|
||||||
@@ -110,7 +113,7 @@ namespace Orchard.TaskLease.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ILifetimeScope EnsureLifetimeScope(string name) {
|
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() {
|
private void DisposeLifetimeScope() {
|
||||||
|
Reference in New Issue
Block a user