Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions docs/csharp/language-reference/compiler-messages/cs8892.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: "Compiler warning (level 5) CS8892"
ms.date: 08/26/2020
f1_keywords:
- "CS8892"
helpviewer_keywords:
- "CS8892"
author: Youssef1313
---

# 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:

```csharp
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.

```csharp
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);
}
}
```
Loading