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

  • SEARCH
  • Home
  • 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 8055641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:27:07+00:00 2026-06-05T08:27:07+00:00

I am currently developing a windows service which implements fileSystemWatcher . Videos are uploaded

  • 0

I am currently developing a windows service which implements fileSystemWatcher. Videos are uploaded into a folder at which point the filewatcher fires the created event as below to convert the video.

private void fileSystemWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
{
  if (ConvertVideo(e.FullPath, e.Name))
  {
    WriteToEventLog(String.Format("Successfully converted video - {0}", e.FullPath), EventLogEntryType.Information);
  }            
}

Within ConvertVideo a new process is created but I have run into issues where the process crashes / hangs / disappears and it appears the main thread is then locked as its waiting for WaitForExit() which effectively crashes the service as no other videos can then be converted. How could I avoid locking the entire service if the process dies?

private bool ConvertVideo(string SourcePath, string Filename)
{   
   try
   {
      // Create new process
      ProcessStartInfo startInfo = new ProcessStartInfo();
      startInfo.CreateNoWindow = false;
      startInfo.UseShellExecute = false;
      startInfo.FileName = "C:\Handbrake\HandBrakeCLI.exe";
      startInfo.WindowStyle = ProcessWindowStyle.Hidden;
      startInfo.Arguments = GetArguments(SourcePath, Filename);
      int? exitCode = null;
      using (Process exeProcess = Process.Start(startInfo))
      {
        exeProcess.WaitForExit();
        exitCode = exeProcess.ExitCode;
      }
   }
   catch(Exception ex)
   {
     return false;
   }
}

NOTE: Code is shortened for this example

  • 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-06-05T08:27:08+00:00Added an answer on June 5, 2026 at 8:27 am

    According to MSDN, Process.WaitForExit should return if your process crashes (emphasis added):

    When an associated process exits (that is, when it is shut down by the
    operation system through a normal or abnormal termination), the system
    stores administrative information about the process and returns to the
    component that had called WaitForExit().

    It appears that your HandBrake process is just hanging and staying alive. The best solution would be to debug that process and figure out where it is crashing, but not closing down. Do you have access to the HandBrakeCLI.exe code?

    If you don’t have access to the HandBrake.exe code: you could use Process.WaitForExit(Int32) to set a timeout. If the timeout is reached, you may want to manually kill your process via the Process.Kill function, or all subsequent calls to Process.Start(ProcessStartInfo) will not work properly, since they will only return a new process if the process wasn’talready running:

    A new Process component that is associated with the process resource,
    or null if no process resource is started (for example, if an existing
    process is reused)
    .

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

Sidebar

Related Questions

I'm currently working on developing a windows service which will be deployed to all
I'm currently developing a WCF service self hosted in a Windows service with the
I'm currently developing a C++ library for Windows which will be distributed as a
i am currently developing a wcf publish subscribe service. On my windows form app,
I'm currently developing a .NET Windows Service and am curious about how references vs.
I am currently developing a WCF Publish Subscribe service on a windows form application.
I am currently developing a WCF Publish Subscribe service in a windows form project.
We're developing a windows service which will act as a sort of 'slave' process.
We are currently developing a Windows Forms application in VS 2008 C#. This application
I am currently developing an application for Windows CE on the TI OMAP processor,

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.