I have a problem with my PictureBox after executing a process. At the time I call the process, that just executes a batch file, the PictureBox (displaying a GIF animation) freezes.
I want to click the button that starts the process and show the PictureBox displaying the GIF animation, and after the process is done I want to hide the PictureBox.
Does anyone know how to achieve this?
Here's my code:
// My executeCmdCommand
public void executeCmdCommand(string argument)
{
var arg0 = argument; // Path
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C " + arg0;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
private void button1_Click(object sender, EventArgs e)
{
DisplayImage();
string cmdCom = @"C:\Users\Mim\Desktop\test.bat";
executeCmdCommand(cmdCom);
HideImage();
}
private void DisplayImage()
{
imageControl.Show();
//PictureBox imageControl = new PictureBox();
imageControl.Width = 400;
imageControl.Height = 400;
Bitmap image = new Bitmap(@"C:\Users\foobar\Desktop\loading.gif");
imageControl.Dock = DockStyle.Fill;
imageControl.Image = (Image)image;
Controls.Add(imageControl);
}
private void HideImage()
{
imageControl.Hide();
}