Pause and resume an application

  • Thread starter Thread starter emr
  • Start date Start date
E

emr

Hi, here is my application deletes temporary files. Sometimes it takes too
much time to delete, how can i pause and resume the application pressing a
button. i don't want to suspend and resume a thread if there is an other
way. Thank you.
Thread thread2=new Thread(new ThreadStart(deltmpfiles));

thread2.Start();

FileStream fs= new FileStream(Directory.GetCurrentDirectory() +
"\\tempfilelist.dat",FileMode.Open);

StreamReader reader= new StreamReader(fs);

while(reader.Peek() != -1)

{

DirSearch(systemdrive + "\\",reader.ReadLine());

}

progressBar1.PerformStep();
 
Hi,

I am a game developer therefore I use pause very often, what I do is on the
loop that you r processing create an IF statement

While (whatever)
{
if (Running)
do whatever you want to do
}

Running is a module level variable that can be accessed by any thread.

This is very easy to implement.
Hope this helps

Salva
 
Back
Top