[C#] async/await Type Checking?

I regularely stumble across the issue where I forget to write await in front of async calls.

For the return value I often use var syntax which gets implicitely something like Task<int>. 

 

Is there a way to get a notification when async calls are used without await?

Another nice way would be to get a notification when var is used with async calls.

 

i.e.:

var returnValue = DoSomethingAsync()

0
1 comment

There are times when you don't want to use "await" - for example, if you're kicking off multiple tasks to run in parallel, and then using "await Task.WhenAll(...)" to wait for them all to complete.

If the task returns a value, and you forget the "await", then you'll get an error when you try to use the returned value. If the task doesn't return a value, and you never await it, you'll get a warning that the method could return before the task completes.

0

Please sign in to leave a comment.