My program is in win forms (c#). It should open an external program, do a printscreen of it's main window, and close it. By using Process.Start() I can open the the program, but then all the focus is on it and my code is halted. Only when I close it myself my form continues- but it's too late for the screenshot. So how do I force my code to keep running?
public void Runttk(string maromnum)
{
Process runttk = new Process();
runttk.StartInfo.UseShellExecute = true;
runttk.StartInfo.FileName = @"C:\\program.exe";
runttk.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
runttk.Start();
this.Focus();
try
{
if (runttk.WaitForInputIdle()==true)
{
PringJpg(maromnum);
Killttk();
}
}
catch (Exception e)
{
}
}
Thank you
UPDATE: eventuanlly I've used Thread.Sleep(3000). Crued but do the trick. I didn't used backgroundworker because the sync between the finale uplaod the the extenral program and my code wasn't clear enough.