You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Method 'method' will not be used as an entry point because a synchronous entry point 'method' was found.
14
+
15
+
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.
16
+
17
+
Because async main was only supported starting with C# 7.1, this warning isn't generated for projects targeting a previous version.
18
+
19
+
> [!NOTE]
20
+
> The compiler always uses the synchronous entry point. In case there are multiple synchronous entry points, you get a compiler error.
21
+
22
+
## Example
23
+
24
+
The following examples generates CS8892:
25
+
26
+
```csharp
27
+
usingSystem;
28
+
usingSystem.Threading.Tasks;
29
+
30
+
publicclassProgram
31
+
{
32
+
// CS8892: Method 'Program.Main()' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found.
33
+
publicstaticasyncTaskMain()
34
+
{
35
+
awaitTask.Delay(1);
36
+
}
37
+
38
+
publicstaticvoidMain(string[] args)
39
+
{
40
+
Console.WriteLine(2);
41
+
}
42
+
}
43
+
```
44
+
45
+
## How to fix this warning
46
+
47
+
Keep only the intended entry point for your program, and rename the others.
0 commit comments