© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
3 replies
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 ;)
}
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

automapper in net framework
C#CC# / help
4y ago
✅ oauth in asp net framework?
C#CC# / help
3y ago
dependency injection in net framework
C#CC# / help
4y ago