我正在嘗試做一個進度條表單加載和加載時,如果我按下取消按鈕,整個應用程序將停止它正在做的任何事情。如何在進度條上按取消按鈕時停止程序c#
下面是我的代碼調用進度條窗體。我想知道任何人都可以幫忙嗎?
Loading loader = new Loading();
private void lockButton_Click(object sender, EventArgs e)
{
if (this.ddCheckBox.Checked == false)
{
if (this.passwordtextBox.Text == "")
{
MessageBox.Show("Please enter a password!");
}
else if (this.retypeTextBox.Text == "")
{
MessageBox.Show("Please retype password!");
}
else if (this.passwordtextBox.Text == this.retypeTextBox.Text)
{
//details = new Details();
details.SetPassword(this.passwordtextBox.Text);
if (this.EncryptionComboBox.Text == "AES - 128 bit" | this.EncryptionComboBox.Text == "AES - 192 bit" | this.EncryptionComboBox.Text == "AES - 256 bit")
{
this.Hide();
Thread thread = null;
thread = new Thread(new ThreadStart(delegate() { loader.dLabel.Text = "Locking Files..."; loader.ShowDialog(); }));
thread.Start();
details.SetEncryption(this.EncryptionComboBox.Text);
+1同意。後臺工作人員已經在右側建立了取消規定。 –