I have a class heirarchy of:
class BaseProcess
{
public virtual void Execute() = 0;
};
class SubProcess : BaseProcess
{
public virtual void Execute()
{
//Do Something
//Need to call back to the GUI here, maybe to get a file path from a file selector
//Do Something Else
//Now want to update the GUI with the progress of the operation perhaps
//More processing
}
};
Assuming that a SubProcess object is created and called from a GUI button event handler…
My question is what is the best way to interact with the GUI from within the Execute() function? (Also assuming that that Execute() may be running on a different thread)
The idea I had was to pass a Callback into the SubProcess object, as this would allow me to send info to the GUI, however in the case of a File Selector, what would be the best way to get the data back to the SubProcess object? I would like the solution to be as generic as possible so I could return different types of data, depending on the request.
Note: Please ignore any code mistakes, I knocked the sample together quickly just to illustrate the problem
Update:
Sorry to be clear, this would be on Windows, MFC. I’m not sure how much this matters as I think the overall design should be applicable to most GUI frameworks?
And in the window class: