Skip to content
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

Add WaitAndUnwrapException for ValueTask #246

Open
GSPP opened this issue Dec 30, 2021 · 2 comments
Open

Add WaitAndUnwrapException for ValueTask #246

GSPP opened this issue Dec 30, 2021 · 2 comments
Assignees

Comments

@GSPP
Copy link

GSPP commented Dec 30, 2021

This is a useful little helper method. Would be useful for ValueTask, too.

@StephenCleary StephenCleary self-assigned this Dec 30, 2021
@StephenCleary
Copy link
Owner

There are some APIs in this library (like WaitAndUnwrapException) that are not really recommended, but included either for historical reasons or because they've got some sharp corners in their implementation.

It may make sense to bring this API forward for ValueTask, but I'll have to think about it. It also wouldn't be recommended, and the implementation is the same as the workaround for the missing API: just call AsTask followed by WaitAndUnwrapException. I'm leaning against including this API for ValueTask because waiting on value tasks isn't permitted (so this API would muddy the waters for devs learning about value tasks), but I'll think about it.

@GSPP
Copy link
Author

GSPP commented Dec 31, 2021

Right, so my motivation is to use this in cases where sync-over-async is warranted. These cases do exist. It can be due to an interface, but it can also be useful in an application that does not benefit from async IO when you have to use an async-only library. Then, instead of infecting everything with async for zero gain, you just block in a few places. I understand that the .NET community has developed an outright disdain for doing so but I believe it to be a rational engineering choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants