Starting async method as Thread or as Task

后端 未结 5 2118
Happy的楠姐
Happy的楠姐 2021-02-20 17:23

I\'m new to C#s await/async and currently playing around a bit.

In my scenario I have a simple client-object which has a WebRequest

5条回答
  •  伪装坚强ぢ
    2021-02-20 18:08

    Edited as previous answer was wrong:

    As it's in the constructor, I think you would have to spin up a new thread for it. I would personally do that using

    Task.Factory.StartNew(() => SendAliveMessageAsync());

提交回复
热议问题