Show / Hide Table of Contents

Cancelling a request

All requests to the IPFS engine can be cancelled by supplying an optional CancellationToken. When the token is cancelled, a TaskCanceledException will be thrown.

Here's a contrived example (unit test) that forces the getting of info on the local IPFS server to be cancelled

var cts = new CancellationTokenSource(500);
try
{
    await Task.Delay(1000);
    var peer = await ipfs.Generic.IdAsync(cts.Token);
    Assert.Fail("Did not throw TaskCanceledException");
}
catch (TaskCanceledException)
{
    return;
}

See also Task Cancellation

  • Improve this Doc
Back to top Generated by DocFX