Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Just to clarify, what I'm trying to confirm is whether the interface must return a Task and have its method awaited. And the answer - which is what I was already 90% sure of - is that it depends on the implementation of the interface. It seems a tiny bit odd to have to create the interface around the implementation. The implementation could change. It's a leak. It's a real scenario, but it's manageable (as evidenced by everyone managing it) and the 50ms rule of thumb helps. Commented May 3, 2019 at 18:23
  • If by that you mean "async is not part of the interface contract," you're right. Returning a Task in the interface method definition compels the client to deal with the method in an asynchronous way (although not necessarily using the await keyword), but the reverse is not true: a method that returns Type T in an interface can still be made asynchronous in the implementation. Commented May 3, 2019 at 18:29
  • In short, an interface cannot reliably dictate the contract of a method with respect to asynchrony. Commented May 3, 2019 at 18:32
  • I'm marking this as the answer because the first sentence tells me what I need. As mentioned in other comments I think I added too much "noise" to my question. Thanks. Commented May 5, 2019 at 23:31