Jump to content

How do I use ProgressEventHandler?


Recommended Posts

ProgressEventArgs should have taken integer parameter, not double. The precision doesn't get used. Paint.NET UI doesn't show decimal places when saving.

 

1. progress = (current_index / maximum) * 100

2 Then round this value to nearest integer

3. Check the value if it equals to the previous calls' progress value.

4. If it's not equal, call the event handler, otherwise don't call it. Because you wouldn't want to call the event handler too frequently with the same values. This would just make UI thread busy and slows down the process. I don't know if Paint.NET prevents unnecessary calls here.

Edited by otuncelli
  • Upvote 2
Link to comment
Share on other sites

2 hours ago, otuncelli said:

2 Then round this value to nearest integer

3. Check the value if it equals to the previous calls' progress value.

4. If it's not equal, call the event handler, otherwise don't call it. Because you wouldn't want to call the event handler too frequently with the same values. This would just make UI thread busy and slows down the process. I don't know if Paint.NET prevents unnecessary calls here.

 

Don't worry about these. Paint.NET already does the right thing here.

  • Upvote 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

The progress handler allows paint.net to throw the OperationCanceledException (if SupportsCancellation is set). This may be important to allow a fluid change of parameters by the user if the save operation is slow and/or the image is quite large. So you should not suppress progress calls.

 

I'm happy that the progress parameter is not an int. This allows to show a higher granulation without an interface change.

 

midoras signature.gif

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.

 Share

×
×
  • Create New...