There are two objects. The Windows Form with a button and a progress bar, and another object that handles an algorithm.
In the algorithm object there is an event, and a property. The event is ProgressChanged
, and the property is Progress
(which is an int).
In the calling window, the button starts off a set of steps in the algorithm object. As each step (or substeps) occurs, the ProgressChanged event fires, and in the window there is an event handler that essentially increments the progress bar relative to the Progress property.
The problem I am running into is that because the algorithm has a possibility (and high liklihood) of running a relatively long time, I need to move it into it's own background thread and push the event back up to the window.
My issue is that I'm not completely sure what I'm doing when it comes to multi-threading. I've looked at Control.Invoke
and I'm a little lost.
Can someone point me in the right direction?