Reputation: 51
I'm trying to get a form to open before loading a function. My problem persists in that I have a function that runs, and I would like feedback given to a user, so they know this function is running. The problem occurs in the sense that the function runs fine, but the form doesn't open until the function is finished, which is pointless. I've researched EventHandlers to force the form to show before the function is executed. The code I devised is really simple, and I don't understand why it doesn't work:
Form formLoad = new Form();
// Declare New Form
public Backing_Up()
{
InitializeComponent();
formLoad.Shown += new EventHandler(formLoad_Shown);
}
public void formLoad_Shown(object sender, EventArgs e)
{
MessageBox.Show("Here");
Backup(fpath, cpath);
//Start Backup Function
}
So I've placed a MessageBox to show that the EventHandler has executed, but that entire function (formLoad_Shown) doesn't run completely. Am I overlooking something really simple? Thanks
Upvotes: 0
Views: 283
Reputation: 2085
For that to work you need to Show the form first.
Form formLoad = new Form();
// Declare New Form
formLoad.Show();
Upvotes: 2