Using async without await in C#?

前端 未结 4 978
别那么骄傲
别那么骄傲 2020-12-05 04:43

Consider Using async without await.

think that maybe you misunderstand what async does. The warning is exactly right: if you mark your method async

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 05:05

    If your Logger.LogInfo is already async this is enough:

    public void PushCallAsync(CallNotificationInfo callNotificationInfo)
    {
        Logger.LogInfo("Pushing new call {0} with {1} id".Fill(callNotificationInfo.CallerId,
    }
    

    If it is not just start it async without waiting for it

    public void PushCallAsync(CallNotificationInfo callNotificationInfo)
    {
        Task.Run(() => Logger.LogInfo("Pushing new call {0} with {1} id".Fill(callNotificationInfo.CallerId));
    }
    

提交回复
热议问题