Skip to content

diagnostic: document waithandle keyword #40852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 18, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/core/diagnostics/dotnet-trace.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dotnet-trace collect [--buffersize <size>] [--clreventlevel <clreventlevel>] [--
| `compilationdiagnostic` | `0x2000000000` |
| `methoddiagnostic` | `0x4000000000` |
| `typediagnostic` | `0x8000000000` |
| `waithandle` | `0x40000000000` |

You can read about the CLR provider more in detail on the [.NET runtime provider reference documentation](../../fundamentals/diagnostics/runtime-events.md).

Expand Down
3 changes: 3 additions & 0 deletions docs/fundamentals/diagnostics/runtime-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@

[Tiered compilation events](runtime-tiered-compilation-events.md)\
These events collect information about tiered compilation.

[Wait handle events](runtime-wait-handle-events.md)\
These events collect information about wait handles. They help to diagnostic thread pool starvations.

Check failure on line 48 in docs/fundamentals/diagnostics/runtime-events.md

View workflow job for this annotation

GitHub Actions / lint

Files should end with a single newline character

docs/fundamentals/diagnostics/runtime-events.md:48:101 MD047/single-trailing-newline Files should end with a single newline character https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md047.md
54 changes: 54 additions & 0 deletions docs/fundamentals/diagnostics/runtime-wait-handle-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "Wait handle runtime events"
description: See ETW events that collect information specific to the wait handles.
ms.date: "05/27/2024"
helpviewer_keywords:
- "wait handle events (CoreCLR)"
- "ETW, EventPipe, LTTng wait handle events (CoreCLR)"
---

# .NET runtime wait handle events

These runtime events capture information about wait handles. They can be useful to investigate thread pool starvation issues. For more information about how to use these events for diagnostic purposes, see [logging and tracing .NET applications](../../core/diagnostics/logging-tracing.md)

## WaitHandleWaitStart event

This event is emitted at the start of a wait operation on a wait handle. Here is a non-exhaustive list of managed method that could emit this event:
- `Monitor.Wait`

Check failure on line 17 in docs/fundamentals/diagnostics/runtime-wait-handle-events.md

View workflow job for this annotation

GitHub Actions / lint

Lists should be surrounded by blank lines

docs/fundamentals/diagnostics/runtime-wait-handle-events.md:17 MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- `Monitor.Wait`"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md
- `Monitor.Enter` or the C# lock keyword
- `ManualResetEvent.WaitOne`
- `Task.Wait`

|Keyword for raising the event|Level|
|-----------------------------------|-----------|
|`WaitHandleKeyword` (0x40000000000)|Verbose (5)|

The following table shows event information.

|Event|Event ID|Raised when|
|-----------|--------------|-----------------|
|`WaitHandleWaitStart`|301|A wait starts.|

|Field name|Data type|Description|
|----------------|---------------|-----------------|
|`WaitSource`|`win:UInt8`|`0x0` - Other sources.<br /><br /> `0x1` - The wait originated from managed code through the `Monitor.Wait` method.|
|`AssociatedObjectID`|`win:Pointer`|Address of the associated object (e.g. address of `obj` in the code `lock(obj) {}`).|
|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.|

## WaitHandleWaitStop event

This event is emitted at the end of a wait operation on a wait handle.

|Keyword for raising the event|Level|
|-----------------------------------|-----------|
|`WaitHandleKeyword` (0x40000000000)|Verbose (5)|

The following table shows event information.

|Event|Event ID|Raised when|
|-----------|--------------|-----------------|
|`WaitHandleWaitStop`|302|A wait stops.|

|Field name|Data type|Description|
|----------------|---------------|-----------------|
|`ClrInstanceID`|`win:UInt16`|Unique ID for the instance of CoreCLR.|

Check failure on line 54 in docs/fundamentals/diagnostics/runtime-wait-handle-events.md

View workflow job for this annotation

GitHub Actions / lint

Files should end with a single newline character

docs/fundamentals/diagnostics/runtime-wait-handle-events.md:54:69 MD047/single-trailing-newline Files should end with a single newline character https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md047.md
Loading