Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6384249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:45:09+00:00 2026-05-25T02:45:09+00:00

I have this compress video task that uses an external program to do it

  • 0

I have this compress video task that uses an external program to do it in c#. It takes some time for this compression to finish and the file to write out. I don’t want to run the next piece of code until I know the external operation has had time to finish.

Do I want to do a simple Thread.sleep(some guess); and then run the next line of code or is there a better way?

this is how I am doing the compressing of the video:

 try
        {
            String finalCommand = "";
            String thePath = System.IO.Path.GetDirectoryName(fileName);
            finalCommand ="-i " + fileName + " -s 320x240 -b 300k -r 30 -f avi " + thePath + "\\C" + System.IO.Path.GetFileName(fileName);
            System.Diagnostics.ProcessStartInfo ffmpegcmd = new System.Diagnostics.ProcessStartInfo(Application.StartupPath + "\\ffmpeg.exe",
                 "-i \""  +  fileName + "\" -s 320x240 -b 300k -r 30 -f avi \"" + thePath + "\\C" + System.IO.Path.GetFileName(fileName) + "\"");

            ffmpegcmd.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            System.Diagnostics.Process p = System.Diagnostics.Process.Start(ffmpegcmd);
            LogUtil.writeLog("About to wait for FFMPEGCMD process");
            p.WaitForExit();
            success = true;
            LogUtil.writeLog("FFMPEGCMD process exited perfectly!");
        }
        catch (Exception ex)
        {
            LogUtil.writeLog("ERROR compressing and using FFMPEG");
            success = false;
        }

though I realize I am not sure if this is doing a process/thread on its own hmm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:45:10+00:00Added an answer on May 25, 2026 at 2:45 am

    If you’re using a new thread, you can just call Thread.Join:

    Thread.Join(otherThread);
    

    … possibly with a timeout.

    In .NET 4 you can use the Task Parallel Library (creating a Task or Task<TResult>) and then call Wait. (If you’re using .NET 4, the TPL is definitely the way to go in general – you can do lots of stuff with it.)

    Both of these approaches are blocking – they will stop the waiting thread from doing anything else until the other task has completed; this isn’t something you want to do in the UI thread. So if this is in the context of a user interface, it would be best to use a callback instead – make the other task call back into the UI thread when it’s done; that can kick off the next piece of code.

    EDIT: The code you’ve shown is creating a new process, not a new thread. You may also be doing it in a new thread, but you haven’t shown that. It’s also still unclear whether this is all taking place in a UI such as Windows Forms or WPF, or whether it’s just a console app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory that contains several files. I want compress this folder to
I have a C# program that uses a production grammar to generate 3D models
I have found this code to make php file cache and compress. Below is
I have this code in jQuery, that I want to reimplement with the prototype
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have this line in a useful Bash script that I haven't managed to
I have a .NET web service that returns XML, and I'd like to compress
I have a script that appends some rows to a table. One of the
I currently have this script to compress log files: find . -name '*.log' -print0
I have this code: # File: zipfile-example-1.py import zipfile,os,glob file = zipfile.ZipFile(Apap.zip, w) #

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.