public void Dispose() { if (!_isWriterLock) { ReleaseReaderLock(); return; } #region Logging the action string methodInfo = string.Empty; if (RuntimeInformation.IsUnittest) { var stackTrace = new StackTrace(); StackFrame stackFrame = (from sf in stackTrace.AsQueryable() where sf.GetMethod().DeclaringType.Assembly.FullName.Contains("Composite.Test") select sf).FirstOrDefault(); if (stackFrame != null) { methodInfo = ", Method: " + stackFrame.GetMethod().Name; } } Log.LogVerbose(LogTitle, "Writer Lock Releasing (Managed Thread ID: {0}, Source: {1}{2})".FormatWith(Thread.CurrentThread.ManagedThreadId, _lockSource, methodInfo)); #endregion ReleaseWriterLock(); }
internal LockerToken(bool writerLock, string lockSource) { _isWriterLock = writerLock; _lockSource = lockSource; if (!writerLock) { AcquireReaderLock(); return; } Verify.ArgumentCondition(!lockSource.IsNullOrEmpty(), "lockSource", "Write locks must be obtained with a string identifying the source"); #region Logging the action string methodInfo = string.Empty; if (RuntimeInformation.IsUnittest) { var stackTrace = new StackTrace(); StackFrame stackFrame = (from sf in stackTrace.AsQueryable() where sf.GetMethod().DeclaringType.Assembly.FullName.Contains("Composite.Test") select sf).FirstOrDefault(); if (stackFrame != null) { methodInfo = ", Method:" + stackFrame.GetMethod().Name; } } Log.LogVerbose(LogTitle, "Writer Lock Acquired (Managed Thread ID: {0}, Source: {1}{2})".FormatWith(Thread.CurrentThread.ManagedThreadId, lockSource, methodInfo)); #endregion Logging the action AcquireWriterLock(); }