5

In .net 4.0, I use Task.ContinueWith regularly. But then I spotted "task.GetAwaiter()" which seems to have the same purpose.

What is the difference?

Community
  • 1
  • 1
Brent Arias
  • 29,277
  • 40
  • 133
  • 234

1 Answers1

8

If you're targeting .NET 4, you'd use ContinueWith.

In general, you wouldn't normally use task.GetAwaiter(). This method exists in order to support the await keyword, and is not part of .NET 4 (it's added in 4.5). This isn't something you'd typically use directly yourself, but instead write it as part of an async method.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373