I'm pretty good with one form, but after I add a new form to the project, things get nasty. For example, in my first form (frmMain) it loads a new constructor which also opens the second form (frmInit). frmInit acts like a flash window that does some networking initialization. That's fine and dandy. After it's done, it should close itself with this.Close(); Unfortunately, it throws an error at me saying it can't do this when the object is disposed.
Error:
Can not access a disposed object.\r\nObject name: 'frmMain'.
Here's the code in action:
// loads initForm
public frmMain()
{
InitializeComponent();
frmInit initForm = new frmInit();
initForm.Show();
}
frmInit initializing itself and displays progress bar of networking progress.
public frmInit()
{
InitializeComponent();
this.Show();
this.Update();
StartProgressBar();
}
At the end of the progress bar before it closes, it attempts to close the form.
this.Close();
Now, this.Close() can't close because of this constructor problem. I'm not entirely sure how forms communicate with each other in C#. It is definitely tricky. Makes Win32 API seem easy, but this is a good learning experience here. Please help if you can.
Thanks,
Phil