I am new at c# so i am not even sure if this is possible.
This application i am making is a win app and its purpose is to make xor encrypted file.
when i try to encrypt large file it takes long time so i am trying to make the program to ask user if he or she wants to continue when they click anywhere on the program.
this is the function which i want to pause when someone click anywhere on the program:
private bool encryptt()
{
int let = 0;
long length;
fl.go = true;
FileStream open = new FileStream(fl.open, FileMode.Open);
FileStream save = new FileStream(fl.save, FileMode.OpenOrCreate);
length = open.Length;
this.enc_progressbar.Maximum = Convert.ToInt32(open.Length);
while(length > open.Position && fl.go == true)
{
if (fl.key.Length != let)
{
save.WriteByte(Convert.ToByte(open.ReadByte() ^ fl.key[let]));
this.enc_progressbar.Value++;
let++;
}
else
{
let = 0;
}
while (fl.pause == true) ;
}
open.Close();
open.Dispose();
save.Close();
save.Dispose();
if(fl.go == true)
{
return true;
}
else
{
File.Delete(fl.save);
return false;
}
}
basically i want this code to be activated while the function above is active:
if (fl.go == true)
{
fl.pause = true;
DialogResult d = MessageBox.Show("Did you want to cancel this process.", "Stop Process", MessageBoxButtons.YesNo);
if (d == DialogResult.Yes)
{
fl.go = false;
}
}
if u need any information on what the code above is doing please ask me.