In two words - this is impossible.
If you understand what WCF call is by its nature, it becomes obvious.
Looking on your example, what we see generally:
Two separate machine A and B, connected via networks.
On machine A you have some component which listen a socket, and when it gets a command it starts synchronous long computation RemoteCall()
.
On machine B you have a client which has two autogenerated methods in fact
BeginRemoteCall->IAsyncResult
+ EndRemoteCall(IAsyncResult)
.
New Task based version of asynchronous call (aka RemoteCallAsync()->Task
) by the nature is absolutely the same, and you can always create your own task using TaskFactory.FromAsync(BeginRemoteCall,EndRemoteCall)->Task
When you call BeginRemoteCall
on the client, you send the command to the second machine "please start computation", and then you add a callback,
which will be called, when calculation is done and results came. Internally this async implementation uses I/O completion ports and allows your client to be non-blocking.
But there is no way to cancel an operation on the server side, if it is already started. You may not be interested in results, you may ignore your callback, but the computation on the server side will be finished anyway.
That's it
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…