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

AV1820 : Async usage #163

Closed
Kryptos-FR opened this issue May 16, 2018 · 1 comment
Closed

AV1820 : Async usage #163

Kryptos-FR opened this issue May 16, 2018 · 1 comment

Comments

@Kryptos-FR
Copy link

It just adds the necessary logic to allow releasing the current thread, and marshal the result back on that same thread [...]

This depends on the current SynchronizationContext and/or TaskScheduler (default one for GUI thread resumes on same context) and whether ConfigureAwait() was specified or not.

In other words, use async only for I/O bound operations.

It seems too restricitve. There are other scenarios where async/await might make sense. For example to make a UI responsive. Additionally, much like the IDisposable patter, async/await is a kind of "contaminating" pattern and when you start using it you often have to go all the way and make other methods async as well, avoiding the smelly async void case.

@dennisdoomen
Copy link
Owner

This depends on the current SynchronizationContext and/or TaskScheduler (default one for GUI thread resumes on same context) and whether ConfigureAwait() was specified or not.

You're right. We need to rephrase that.

For example to make a UI responsive.

If it involves an I/O intensive operation, then yes. But if it's CPU bound, you'll need to queue a task using the Task.Run, right?

mapfel pushed a commit to stepahead/CSharpGuidelines that referenced this issue Mar 22, 2021
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