Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Missing await warning
Missing await warning

Missing await warning

Morten Hartlev Lindhart

|
2,136 installs
| (4) | Free
Gives a warning when an asynchronous method might be inadvertently used as a fire and forget method (also in cases where the normal CS4014 warning is not).Gives a warning
Download

NOTE: This extension is no longer being updated. It is recommended to use the NuGet analyser package instead.

When using dependency injection and async-await pattern it is possible to end up with an interface with a method that returns a Task. If this interface method is used in a synchronous method there is a likelihood that it will erroneously be run as a fire and forget method (which will not trigger inbuilt warning CS4014). In this situation this analyser generates a warning.

It would be preferable to download the corresponding NuGet package to the relevant projects. This will then be referenced as an analyser that will run on all builds (this extension merely shows the warning when a code file is open, not on build).

Example:

using System.Threading.Tasks;

namespace AsyncAwaitProblem
{
	public interface ICallee
	{
		bool ProblemSolved { get; }
		Task SolveProblemAsync();
	}

	public class Callee : ICallee
	{
		public bool ProblemSolved { get; set; }

		public async Task SolveProblemAsync()
		{
			await Task.Delay(10);
			ProblemSolved = true;
		}
	}
	
	public class Caller
	{
		public bool DoCall()
		{
			ICallee xxx = new Callee();

			// This analyser will give a warning at the following line
			xxx.SolveProblemAsync(); // This is most likely an undesired fire and forget. 

			return xxx.ProblemSolved; // Will return false - we expected it to return true
		}
	}
}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft