I am working on a winforms project. I am implementing an MVP architecture. I have some processing intensive jobs running at the presenter (Reading from file system and performing bulk inserts to a DB). I would like to perform these operations in a background thread without locking up the UI and update controls on my view (progress bar, and datagridview).
Should I just access the backgroundworker object within my presenter and handle it's events in the presenter by having the view event handlers trigger events that the presenter is listening to??
For example:
In the VIEW:
private void backgroundWorker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
if (WorkerProgressChange != null)
{
WorkerProgressChange(this, EventArgs.Empty);
}
}
In the Presenter:
_view.WorkerProgressChange += UpdateView;
Does this seem reasonable? Can someone offer a better model?
Thanks!