-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Make the PeriodicTimer.WaitForNextTickAsync description more descriptive #119637
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the documentation for the PeriodicTimer.WaitForNextTickAsync method by clarifying the boolean return value semantics and the different completion states of the returned ValueTask.
Key Changes
- Enhanced the XML documentation to explicitly describe when the method returns
truevsfalse - Added clarification about the cancellation behavior and task state
|
Tagging subscribers to this area: @mangod9 |
| /// <returns>A <see cref="ValueTask" /> that will be completed due to the timer firing (in which case the result is <c>true</c>), <see cref="Dispose"/> being called to stop the timer (in which case the result is <c>false</c>), or cancellation being requested (in which case the task enters the Canceled state).</returns> | ||
| /// <remarks> | ||
| /// The <see cref="PeriodicTimer"/> behaves like an auto-reset event, in that multiple ticks are coalesced into a single tick if they occur between | ||
| /// calls to <see cref="WaitForNextTickAsync"/>. Similarly, a call to <see cref="Dispose"/> will void any tick not yet consumed. <see cref="WaitForNextTickAsync"/> | ||
| /// may only be used by one consumer at a time, and may be used concurrently with a single call to <see cref="Dispose"/>. | ||
| /// </remarks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to include more descriptive information of the returning ValueTask but including it in the returns section is not consistent with the repository. How about
| /// <returns>A <see cref="ValueTask" /> that will be completed due to the timer firing, <see cref="Dispose"/> being called to stop the timer, or cancellation being requested.</returns> | |
| /// <remarks> | |
| /// The value of the Result property of the returned <see cref="ValueTask" /> is <see langword="true"/> when it's completed due to the timer firing and | |
| /// <see langword="false"/> when the timer is disposed or stopped. | |
| /// A cancelled task is returned if cancellation is requested. | |
| /// The <see cref="PeriodicTimer"/> behaves like an auto-reset event, in that multiple ticks are coalesced into a single tick if they occur between | |
| /// calls to <see cref="WaitForNextTickAsync"/>. Similarly, a call to <see cref="Dispose"/> will void any tick not yet consumed. <see cref="WaitForNextTickAsync"/> | |
| /// may only be used by one consumer at a time, and may be used concurrently with a single call to <see cref="Dispose"/>. | |
| /// </remarks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've adjusted the cancellation line because it's not precise.)
9386b6f to
6f4c619
Compare
The current documentation doesn't actually say what the semantics of the result are.