void Capture::Process() { p("Processing data..."); //Progress p; is a global variable for the class p.Create(); p.Canceled(); DoProcess(); p.Close(); } void Capture::DoProcess() { std::ofstream lockfile (imgjlock); //Create a lockfile, when the external program is done it deletes the lockfile lockfile.close(); ShellExecute(NULL, NULL, batfile, NULL, NULL, SW_HIDE); while(true) { p.Step(); if(!FileExists(imgjlock)) { p.Close(); //Here some code to show the results break; } } } else { remove(imgjlock); } }