简体   繁体   中英

What's the best approach to "CS4014: Because this call is not awaited, execution of the current method continues before the call is completed"?

在此处输入图像描述

Visual Studio is showing this warning on every async task that I do not want to await . Why? I don't want to globally suppress all these warnings, because there may be instances I forget to await, but most of the time when this warning appears, it's because I'm intentionally not awaiting a task. What's the best response to these warnings?

The problem is that it is returning a task, so to not await, the best way is to just set the return to something such as:

_ = SomeAwaitableTask();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM