diff options
Diffstat (limited to 'win/C#/HandBrake.ApplicationServices/Services')
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Services/Encode.cs | 12 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Services/ErrorService.cs | 45 |
2 files changed, 36 insertions, 21 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs index d922b66e6..42d2822ea 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs @@ -346,7 +346,10 @@ namespace HandBrake.ApplicationServices.Services try
{
if (fileWriter != null)
+ {
fileWriter.Close();
+ fileWriter.Dispose();
+ }
}
catch (Exception exc)
{
@@ -430,7 +433,10 @@ namespace HandBrake.ApplicationServices.Services catch (Exception exc)
{
if (fileWriter != null)
+ {
fileWriter.Close();
+ fileWriter.Dispose();
+ }
errorService.ShowError("Error", exc.ToString());
}
@@ -454,12 +460,14 @@ namespace HandBrake.ApplicationServices.Services try
{
- if (fileWriter != null)
+ if (fileWriter != null && fileWriter.BaseStream.CanWrite)
+ {
fileWriter.WriteLine(e.Data);
+ }
}
catch (Exception exc)
{
- // errorService.ShowError("Unable to write log data...", exc.ToString());
+ // errorService.ShowError("Unable to write log data...", exc.ToString());
}
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Services/ErrorService.cs b/win/C#/HandBrake.ApplicationServices/Services/ErrorService.cs index a45cd113f..7b75ce893 100644 --- a/win/C#/HandBrake.ApplicationServices/Services/ErrorService.cs +++ b/win/C#/HandBrake.ApplicationServices/Services/ErrorService.cs @@ -28,8 +28,15 @@ namespace HandBrake.ApplicationServices.Services /// </param>
public void ShowError(string shortError, string longError)
{
- Thread newThread = new Thread(new ParameterizedThreadStart(WriteExceptionToFile));
- newThread.Start(shortError + Environment.NewLine + longError);
+ try
+ {
+ Thread newThread = new Thread(new ParameterizedThreadStart(WriteExceptionToFile));
+ newThread.Start(shortError + Environment.NewLine + longError);
+ }
+ catch (Exception)
+ {
+ // Do Nothing
+ }
ExceptionWindow window = new ExceptionWindow();
window.Setup(shortError, longError);
@@ -37,6 +44,20 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
+ /// Show a Notice or Warning Message.
+ /// </summary>
+ /// <param name="notice">
+ /// The text to display to the user
+ /// </param>
+ /// <param name="isWarning">
+ /// Is a warning window, show the warning icon instead of the notice
+ /// </param>
+ public void ShowNotice(string notice, bool isWarning)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
/// Write Exceptions out to log files
/// </summary>
/// <param name="state">
@@ -44,11 +65,11 @@ namespace HandBrake.ApplicationServices.Services /// </param>
public void WriteExceptionToFile(object state)
{
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
- string file = Path.Combine(logDir, string.Format("Exception_{0}.txt", DateTime.Now.Ticks));
-
try
{
+ string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+ string file = Path.Combine(logDir, string.Format("Exception_{0}.txt", DateTime.Now.Ticks));
+
if (!File.Exists(file))
{
using (StreamWriter streamWriter = new StreamWriter(file))
@@ -64,19 +85,5 @@ namespace HandBrake.ApplicationServices.Services return; // Game over. Stop digging.
}
}
-
- /// <summary>
- /// Show a Notice or Warning Message.
- /// </summary>
- /// <param name="notice">
- /// The text to display to the user
- /// </param>
- /// <param name="isWarning">
- /// Is a warning window, show the warning icon instead of the notice
- /// </param>
- public void ShowNotice(string notice, bool isWarning)
- {
- throw new NotImplementedException();
- }
}
}
|