VeLC Posted April 29, 2022 Share Posted April 29, 2022 (edited) 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 April 29, 2022 by VeLC typo Quote Link to comment Share on other sites More sharing options...
null54 Posted April 29, 2022 Share Posted April 29, 2022 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) ... } 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint 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 More sharing options...
Rick Brewster Posted April 29, 2022 Share Posted April 29, 2022 Yeah although IsCancelRequested is just polling a cancellation token, so it would be simpler for me to just expose the cancellation token 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 30, 2022 Share Posted April 30, 2022 I am planning on adding this for the 4.4 5.0 release. Should be like ... 1 line of code. Edit: 4.4 is now 5.0 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.