EasyCaching icon indicating copy to clipboard operation
EasyCaching copied to clipboard

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

Open albertwoo opened this issue 1 year ago • 1 comments

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

albertwoo avatar Apr 10 '24 06:04 albertwoo

@albertwoo Thanks for your interest in this project.

We will take a look ASAP.

catcherwong avatar Apr 13 '24 00:04 catcherwong