Exemple #1
0
        public TracedLock(TraceableLock traceableLock, TimeSpan?timeout)
        {
            if (timeout == null)
            {
                timeout = TimeSpan.FromSeconds(30);
            }

            _status        = TracedLockStatus.Acquiring;      //useful for detecting dead-lock
            _traceableLock = traceableLock;

            LockAnalyzer.Lock(traceableLock);

            //collect useful information about the context such
            //as stacktrace, time to acquire the lock(T1)
            if (Monitor.TryEnter(_traceableLock, timeout.Value))
            {
                _status = TracedLockStatus.Acquired;
            }
            else
            {
                _status = TracedLockStatus.Timedout;
            }
            //lock is acuired, so collect acquired-time(T2)
            //[T2-T1 = time taken to acquire lock]
        }
Exemple #2
0
        public TracedLock(TraceableLock traceableLock, TimeSpan? timeout)
        {
            if (timeout == null)
                timeout = TimeSpan.FromSeconds(30);

            _status = TracedLockStatus.Acquiring; //useful for detecting dead-lock
            _traceableLock = traceableLock;

            LockAnalyzer.Lock(traceableLock);

            //collect useful information about the context such
            //as stacktrace, time to acquire the lock(T1)
            if (Monitor.TryEnter(_traceableLock, timeout.Value))
            {
                _status = TracedLockStatus.Acquired;
            }
            else
            {
                _status = TracedLockStatus.Timedout;
            }
            //lock is acuired, so collect acquired-time(T2)
            //[T2-T1 = time taken to acquire lock]
        }