I am dealing with running a control in a form, however the form itself is of no value to me. I essentially want the form to run a task and return a value, however for that I
I think the simplest solution is to just raise an event from the form once the task has completed.
void RunTask()
{
Form form = new Form();
form.TaskCompleted += new EventHandler(form_TaskCompleted);
form.Show();
}
void form_TaskCompleted(object sender, EventArgs e)
{
object result = ((Form)sender).GetResult();
}
Edit: Of course you'd want to dispose the form and unhook that event once it's completed etc..