diff --git a/src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs b/src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs index 9c4e732e6..68d488d82 100644 --- a/src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs +++ b/src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs @@ -1066,6 +1066,7 @@ private void CheckSynchronizationContextAppropriateForLock(Awaiter? awaiter) private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendingWriteLockCheck = false) { bool issued = false; + bool isOrdinaryNestedLock = false; // ordinary nested lock is a nested lock always granted immediately. We don't need write ETW event to reduce noise in traces. lock (this.syncObject) { @@ -1108,10 +1109,12 @@ private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendi } issued = true; + isOrdinaryNestedLock = true; } else if (hasRead || hasUpgradeableRead) { issued = true; + isOrdinaryNestedLock = true; } break; @@ -1119,6 +1122,7 @@ private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendi if (hasUpgradeableRead || hasWrite) { issued = true; + isOrdinaryNestedLock = true; } else if (hasRead) { @@ -1137,6 +1141,7 @@ private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendi if (hasWrite) { issued = true; + isOrdinaryNestedLock = true; } else if (hasRead && !hasUpgradeableRead) { @@ -1170,7 +1175,10 @@ private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendi if (issued) { - this.etw.Issued(awaiter); + if (!isOrdinaryNestedLock) + { + this.etw.Issued(awaiter); + } } else {