Noah Mt4跟单系统制作第十篇 锁篇
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Copier.Core { public sealed class KeyLocker<T> : IDisposable { private static readonly object _lockerDictionary = new object(); private static readonly Dictionary<T, LockerObject> _lockerObjects = new Dictionary<T, LockerObject>(); private T _key; public KeyLocker(T key) { _key = key; LockerObject lockerObject; lock (_lockerDictionary) { if (!_lockerObjects.TryGetValue(_key, out lockerObject)) { lockerObject =