First, the client is completely separate from the server. Any client or server can be synchronous, use asynchronous IAsyncResult code (APM) or use async code (TAP).
Secondly, server-side async methods should return Task , even for unidirectional communication. The async equivalent of the synchronous method returning void is the async Task method, not the async void method. async void especially dangerous in WCF services because it can violate ConcurrencyMode .
So, your server side steps will look like this:
- Remove
OperationContract.AsyncPattern . - Combine a pair of
Begin* / End* methods into one *Async method, which returns a Task .
Your client side should see Task regular methods on the interface for its proxy, which should await . This does not mean that you expect an answer; this await allows you to wait for the actual message to be sent (if there are delays) and detect channel communication errors (if you are using a reliable channel).
source share