Bug fix : Crash when closing TBF program (ModelessActivityForm).
This commit is contained in:
parent
604c59723f
commit
99b68f1dd6
@ -40,11 +40,30 @@ namespace TBF.Forms
|
||||
InitializeComponent();
|
||||
ControlBox = false;
|
||||
|
||||
CloseFormHandler += delegate(object sender, EventArgs args)
|
||||
CloseFormHandler += HandleCloseFormCommand;
|
||||
}
|
||||
|
||||
private void ModelessActivityForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }
|
||||
else OnCloseForm(sender, args);
|
||||
};
|
||||
CloseFormHandler -= HandleCloseFormCommand;
|
||||
}
|
||||
|
||||
void HandleCloseFormCommand(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnCloseForm(sender, args);
|
||||
}
|
||||
}
|
||||
|
||||
void OnCloseForm(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ModelessForm_Load(object sender, EventArgs e)
|
||||
@ -79,11 +98,5 @@ namespace TBF.Forms
|
||||
{
|
||||
activityStatusLabel.Text = args.Activity;
|
||||
}
|
||||
|
||||
void OnCloseForm(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
TBF/Forms/ModelessActivityForm.designer.cs
generated
1
TBF/Forms/ModelessActivityForm.designer.cs
generated
@ -60,6 +60,7 @@
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ModelessActivityForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ModelessActivityForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.ModelessForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user