Compiler warning (level 5) CS8892

Method 'method' will not be used as an entry point because a synchronous entry point 'method' was found.

This warning is generated on all async entry point candidates when you have multiple valid entry points, where they contain one or more synchronous entry point and one or more asynchronous entry points.

Because async main was only supported starting with C# 7.1, this warning isn't generated for projects targeting a previous version.

Note

The compiler always uses the synchronous entry point. In case there are multiple synchronous entry points, you get a compiler error.

Example

The following examples generates CS8892:

using System;
using System.Threading.Tasks;

public class Program
{
    // CS8892: Method 'Program.Main()' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found.
    public static async Task Main()
    {
        await Task.Delay(1);
    }

    public static void Main(string[] args)
    {
        Console.WriteLine(2);
    }
}

How to fix this warning

Keep only the intended entry point for your program, and rename the others.

using System;
using System.Threading.Tasks;

public class Program
{
    public static async Task SomeOtherNameAsync()
    {
        await Task.Delay(1);
    }

    public static void Main(string[] args)
    {
        Console.WriteLine(2);
    }
}