Jump to content

[Request] Cancellation Token


VeLC

Recommended Posts

Request: Make PaintDotNet.Effects.Effect.SignalCancelRequest virtual or add a method that returns cancellationTokenSource.Token for code like

Enumerable
  .Range(0, 100,000)
  .AsParallel()
  .AsOrdered()
  .WithCancellation(token)
  ...

 

Edited by VeLC
typo
Link to comment
Share on other sites

Are you looking to make the Effect IsCancelRequested property work with a Cancellation Token?

 

I wrote a class that does this for my Paint.NET G'MIC library: https://github.com/0xC0000054/gmic-sharp-pdn/blob/master/src/CallbackToCancellationTokenAdapter.cs

The following example shows how to use it:

 

using (CallbackToCancellationTokenAdapter tokenSource = new CallbackToCancellationTokenAdapter(() => this.IsCancelRequested))
{
  Enumerable
  .Range(0, 100,000)
  .AsParallel()
  .AsOrdered()
  .WithCancellation(tokenSource.Token)
  ...
}

 

  • Like 1

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...