-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Code Quality: Introduced a wrapper for non-blocking await on a sync method #17100
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
Requesting your review @dongle-the-gadget @hez2010 |
} | ||
}); | ||
|
||
HANDLE* pEventHandles = stackalloc HANDLE[1]; |
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.
Do you even need to allocate a stack here? I thought your HANDLE variable is in stack already.
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.
Related to your 2nd comment, it looks like you can't take address of a local variable that goes thru an async lambda/function. The current code doesn't have async and initially did so this can be refactored but IIUC if we wanna use async void we may have to do this.
IntPtr eventHandle = CreateEvent(IntPtr.Zero, true, false, null); | ||
|
||
Task.Run(() => | ||
STATask.RunAsSync(() => |
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.
Is there a reason why async void isn't desirable here?
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.
So you mean adding Wait() in that helper method instead?
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 mean making it an async lambda and then await
.
Resolved / Related Issues
Steps used to test these changes