2

I developed a C# application which starts the git(.exe) process and asynchronously reads the output lines of the process. Executing a git pull, results in multiple output lines.

E.g.

Receiving objects: 9% (10/109)
Receiving objects: 10% (11/109)
Receiving objects: 11% (12/109)
Receiving objects: 12% (14/109)

Is it possible to (automatically) determine the end of the result of a Git command, so I can stop the asynchronous read operations and the Git process? Does a Git result contains (a) special character(s) or keyword which represent the end of the result?

Most examples on the web use a console application where the user must manually quit the console to end the git process as well.

Thank you in advance!

Edit 1:

Code example

gitProcess.Start();

gitProcess.BeginOutputReadLine();
gitProcess.BeginErrorReadLine();

gitProcess.WaitForExit(200);
gitProcess.Close();
Odrai
  • 2,163
  • 2
  • 31
  • 62
  • Possible duplicate of [Wait till a process ends](https://stackoverflow.com/questions/3147911/wait-till-a-process-ends) – max630 Oct 22 '17 at 07:07
  • 1
    @max630 This is not a duplicate! I already know how to end a process, but the question is: 'When is a Git command finished, so I can stop the process as well). – Odrai Oct 22 '17 at 07:54
  • When git program finishes, it stops, as any other command. – max630 Oct 22 '17 at 08:21
  • @max630 I added a code example in the OP. If I execute a Git pull command, which takes up to 30 seconds to complete, doesn't the WaitForExit(200) stop the Git process too early? – Odrai Oct 22 '17 at 10:04
  • I think it should looks like this https://stackoverflow.com/a/13746202/2303202 – max630 Oct 22 '17 at 10:22

0 Answers0