A
Anderson Takemitsu Kubota
Hi!
I need to run a process that should take over 1 minute, for instance.
I desire to put a button that the user can cancel the process.
For this, I was using the Application.DoEvents in the first process, and several times I verify the value of a m_bCancel variable that informs when the user requests the application to cancel.
This is the code I've being implementing on the cancel button is something like this:
private void btnCancel_Click(object sender, System.EventArgs e)
{
if(m_bRunning)
{
AddStatus("Process is being aborted...");
m_MainProcess.SetCancel(true);
int nCount = 0;
while(nCount < 5)
{
Application.DoEvents();
if(m_bRunning)
Thread.Sleep(1000);
else
break;
nCount++;
}
}
m_bCancel = true;
FinishProcess();
this.Close();
this.Dispose();
Application.Exit();
}
The problem is that the application remains on memory even after the Application.Exit() statement is executed.
Is it possible to do what I desire in a single thread?
Thank you.
Anderson T. Kubota
I need to run a process that should take over 1 minute, for instance.
I desire to put a button that the user can cancel the process.
For this, I was using the Application.DoEvents in the first process, and several times I verify the value of a m_bCancel variable that informs when the user requests the application to cancel.
This is the code I've being implementing on the cancel button is something like this:
private void btnCancel_Click(object sender, System.EventArgs e)
{
if(m_bRunning)
{
AddStatus("Process is being aborted...");
m_MainProcess.SetCancel(true);
int nCount = 0;
while(nCount < 5)
{
Application.DoEvents();
if(m_bRunning)
Thread.Sleep(1000);
else
break;
nCount++;
}
}
m_bCancel = true;
FinishProcess();
this.Close();
this.Dispose();
Application.Exit();
}
The problem is that the application remains on memory even after the Application.Exit() statement is executed.
Is it possible to do what I desire in a single thread?
Thank you.
Anderson T. Kubota