Skip to content

Commit

Permalink
Added timeout for rare case that exiftool becomes unresponsive for an…
Browse files Browse the repository at this point in the history
…y issue.
  • Loading branch information
josemoliver committed Oct 12, 2018
1 parent a0698a2 commit 5064651
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions WeatherTag/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void Main(string[] args)
}


Console.WriteLine("Weather file: " + WeatherHistoryFile);
//Console.WriteLine("Weather file: " + WeatherHistoryFile);

//Load weather history file into stream
try
Expand Down Expand Up @@ -278,8 +278,14 @@ public static DateTime GetFileDate(string file)

public static double CheckExiftool()
{

double exiftoolreturn = 0;

try
{

// Start Process
Process p = new Process();
Process p = new Process();

// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
Expand All @@ -289,13 +295,12 @@ public static double CheckExiftool()
p.StartInfo.FileName = "exiftool.exe";
p.Start();

double exiftoolreturn = 0;

// Read the output stream
try
{

string exiftooloutput = p.StandardOutput.ReadToEnd().Trim();
exiftoolreturn = double.Parse(exiftooloutput);
p.WaitForExit();
p.WaitForExit(8000);
}
catch
{
Expand Down Expand Up @@ -336,7 +341,7 @@ public static string WriteFileInfo(string File, WeatherReading reading)
p.StartInfo.FileName = "exiftool.exe";
p.Start();
output = File + Arguments+" --- " + p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.WaitForExit(10000);

return output;
}
Expand Down

0 comments on commit 5064651

Please sign in to comment.