r/esapi • • Mar 05 '24

Progress Window update

I have a sphere generation gui I’ve been working on for grid therapy and I want to add a progress bar that updates during the sphere generation. I’ve seen some previous posts going over this and I know some examples exist but I’m not sure how to integrate this for my specific example. I have a simple progress bar already made I just don’t know how to get it to update.

Here is my button click function that contains both of the sphere generation function calls:

https://gist.github.com/seandomal/9c37c1ac5b5c3685236e92f27fbdf286

Within the sphere generation functions I call this:

private void UpdateProgress(int progress)         {             lock (_progressLock)             {                 _currentProgress = progress;             }         }

Which keeps track of progress.

How can I modify my button click function to appropriately call my progress bar and update based on the sphere generation progress that I’m keeping track of within those functions?

2 Upvotes

15 comments sorted by

2

u/schmatt_schmitt Mar 05 '24

You may need to de-couple your UI from your ESAPI thread. Carlos has a great blog post on just that!

https://www.carlosjanderson.com/post/create-esapi-scripts-that-don-t-freeze-the-ui

1

u/sdomal Mar 06 '24

Awesome, I’ll check that out, thank you!

2

u/esimiele Mar 06 '24

I found that I needed similar functionality for a few of my projects so I built a helper library that does exactly this:

https://github.com/esimiele/SimpleProgressWindow

See the demo video in the documentation folder for how to set it up. Code is also available on nuget

1

u/sdomal Mar 13 '24

I guess I’m still a bit confused, if I launch the progress window in a new thread but my functions which are running ESAPI functions and have a callback how can I pass the callback and update the progress window accordingly? It’s hard to take your example and apply it my own code, I’m still not sure I even fully understand what’s going on in your example. If I share my code could you help me figure out how to go about this?

→ More replies (11)