-
Hello, I may be missing something but I don't quite understand the doc about CancellationToken
Let's say I use a client with var cancellationToken = new CancellationToken();
var result = await rpc.InvokeWithCancellationAsync<int>("add", [1, 2], cancellationToken); And a server: public class Server {
readonly JsonRpc rpc;
public Server(Stream sender, Stream reader)
{
rpc = JsonRpc.Attach(sender, reader, this);
}
[JsonRpcMethod("add")]
public Task<int> Add(int a, int b) { return Task.FromResult(a + b); }
}
I don't understand the 2nd part about the notification being sent so the server can cancel a the running task. What should I subscribe to to be notified ? Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The server method must take |
Beta Was this translation helpful? Give feedback.
The server method must take
CancellationToken
as its last parameter in order to be notified of the client's request to cancel the call.