Skip to content

System.ObjectDisposedException: Cannot access a disposed object 'System.Threading.SemaphoreSlim' #525

Open
@albertwoo

Description

@albertwoo

Description

I cannot always reproduce this, but this happens in my concurrent test code and my business code is using MemoryLockFactory from EasyCaching.Core.

System.ObjectDisposedException: Cannot access a disposed object.
  Object name: 'System.Threading.SemaphoreSlim'.
     at System.Threading.SemaphoreSlim.WaitAsync(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at EasyCaching.Core.DistributedLock.MemoryLock.LockAsync(Int32 millisecondsTimeout, CancellationToken cancellationToken)

Related code

try {
    if (await distributedLock.LockAsync(3000)) {
       ...
    }
    else {
        throw new Exception("xxx");
    }
}
finally {
    await distributedLock.ReleaseAsync();
}

Specifications

  • Provider : InMemory (version 1.9.2)
  • Interceptor : AspectCore (version 8.0.0)
  • Serializer : not use
  • System : Ubuntu20.04

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions