I created a class that is used to convert a video to an FLV. When the "Convert" method is called, a form is shown to display the conversion progress (I know it is probably bad OOP design to do it this way, but I digress...), and the conversion process begins.
My problem is that I need my main code to wait for the conversion process to end before it proceeds to the next line, and, at the moment, the conversion process happens on a different thread, so the main code keeps running concurrently.
Before I get into specifics, here is an outline of two theoretical solutions to my problem (I don't think either are possible):
Solution 1:
Keep the conversion process running on a separate thread and use a method like this (pseudocode): WaitFor(MyClass.Thread). This theoretical function would pause the code until the specified thread ends.
Solution 2:
Switch the conversion process over to the main thread so that the main calling code CAN'T progress until the conversion process has finished. Then I would need to find a way to have my form (which contains a ProgressBar) run on another thread or somehow update while the conversion process is going.
I really don't think either of these solutions are possible, so I'm very open to suggestions.
I don't want to use the event handling model for this particular case because my class is used in many different instances and it would get messy managing whether an event should be handled one way or another. I also don't want to pass a boolean value to the conversion function that determines what happens when it finishes because I want to keep this class as flexible and modular as possible.
So again, I'm open for any suggestions or input. Thanks.
My problem is that I need my main code to wait for the conversion process to end before it proceeds to the next line, and, at the moment, the conversion process happens on a different thread, so the main code keeps running concurrently.
Before I get into specifics, here is an outline of two theoretical solutions to my problem (I don't think either are possible):
Solution 1:
Keep the conversion process running on a separate thread and use a method like this (pseudocode): WaitFor(MyClass.Thread). This theoretical function would pause the code until the specified thread ends.
Solution 2:
Switch the conversion process over to the main thread so that the main calling code CAN'T progress until the conversion process has finished. Then I would need to find a way to have my form (which contains a ProgressBar) run on another thread or somehow update while the conversion process is going.
I really don't think either of these solutions are possible, so I'm very open to suggestions.
I don't want to use the event handling model for this particular case because my class is used in many different instances and it would get messy managing whether an event should be handled one way or another. I also don't want to pass a boolean value to the conversion function that determines what happens when it finishes because I want to keep this class as flexible and modular as possible.
So again, I'm open for any suggestions or input. Thanks.