C#C
C#12mo ago
Robert

Task.Run() in .net framework

Hi, I'm maintaining an older legacy .net Framework application in which I have a void start() method (that must be void, however now this is intertwined with async await)

public async Task ConnectToSomeService() { ... }

public void StartService()
{
// what's the right way to call this here
  Task.Run(ConnectToSomeService);
  Task.Run( async () => await ConnectToSomeService());
  ConnectToSomeService(); // and disable the warning ;)
}


as far as i understand async () => await is slower but i don't quite grasp the difference.
Was this page helpful?