Skip to content

Commit 3f2f269

Browse files
qmfrederikbrendandburns
authored andcommitted
Don't throw in StreamDemuxer.Dispose (#128)
1 parent b3135f7 commit 3f2f269

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/StreamDemuxer.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Buffers;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.Net.WebSockets;
67
using System.Threading;
@@ -29,10 +30,18 @@ public void Start()
2930

3031
public void Dispose()
3132
{
32-
if (this.runLoop != null)
33+
try
34+
{
35+
if (this.runLoop != null)
36+
{
37+
this.cts.Cancel();
38+
this.runLoop.Wait();
39+
}
40+
}
41+
catch (Exception ex)
3342
{
34-
this.cts.Cancel();
35-
this.runLoop.Wait();
43+
// Dispose methods can never throw.
44+
Debug.Write(ex);
3645
}
3746
}
3847

0 commit comments

Comments
 (0)