Waiting until an external process has been completed

Viewed 8411

I have a method that is called, although I would like the message box to be shown after the method has been completed (right now the message box is shown straight after the method is called):

if (Check == true)
{
    StartConvIpod();
}
else
{

}
MessageBox.Show("Operation Successful!");

StartConvIpod:

      private void StartConvIpod()
        {

            string res = Directory.EnumerateFiles("dump").
    OrderBy(x => File.GetCreationTime(x)).Last();

            string sub = res.Substring(5);

            string sub2 = sub.Substring(0, sub.Length - 4);


            Process p = new Process();
            p.StartInfo.WorkingDirectory = "dump";
            p.StartInfo.FileName = "ffmpeg.exe";
            p.StartInfo.Arguments = "-i " + sub + " -f mp4 -vcodec mpeg4 -b 700k -aspect 4:3 -r 23.98 -s 320x240 -acodec ac3 -ar 48000 iPodConversions\\" + sub2 + ".mp4";
            p.Start();
}
4 Answers
Related