C# How to start an async method without await its complete?

前端 未结 6 1448
醉酒成梦
醉酒成梦 2021-02-05 08:12

Sometimes I need to start an async job which works very slow. I don\'t care if that job success and I need to continue working on my current thread.

Like sometimes I nee

6条回答
  •  借酒劲吻你
    2021-02-05 08:40

    If you need to use async in your function you can also use a discard variable and don't use await. This is also usefull if you have multiple async function calls but you don't need to wait for all of them.

    public async function(){
        var tmp = await asyncfunction();
        ...
        _ = _httpClient.PutAsync(url, content);
        ...
    }
    

提交回复
热议问题