mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
Catch exceptions thrown by FileStream.Dispose()
This commit is contained in:
parent
ee7546da3d
commit
ce064f1f07
|
@ -100,8 +100,14 @@ namespace BililiveRecorder.Core.Recording
|
|||
this.logger.Warning(ex, "Error calling OnRecordFileClosed");
|
||||
}
|
||||
|
||||
file.Dispose();
|
||||
stream.Dispose();
|
||||
try
|
||||
{ file.Dispose(); }
|
||||
catch (Exception ex)
|
||||
{ this.logger.Warning(ex, "关闭文件时发生错误"); }
|
||||
|
||||
try
|
||||
{ stream.Dispose(); }
|
||||
catch (Exception) { }
|
||||
|
||||
this.OnRecordSessionEnded(EventArgs.Empty);
|
||||
|
||||
|
|
|
@ -40,8 +40,11 @@ namespace BililiveRecorder.Flv.Writer
|
|||
if (this.stream is null)
|
||||
return false;
|
||||
|
||||
this.stream.Close();
|
||||
this.stream.Dispose();
|
||||
try
|
||||
{ this.stream.Dispose(); }
|
||||
catch (Exception ex)
|
||||
{ this.logger?.Warning(ex, "关闭文件时发生错误"); }
|
||||
|
||||
this.stream = null;
|
||||
|
||||
return true;
|
||||
|
@ -174,7 +177,15 @@ namespace BililiveRecorder.Flv.Writer
|
|||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.stream?.Dispose();
|
||||
try
|
||||
{
|
||||
this.stream?.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger?.Warning(ex, "关闭文件时发生错误");
|
||||
}
|
||||
|
||||
this.stream = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user