Skip to content

Commit 1e16ce1

Browse files
authored
Merge pull request #3 from pikepikeid/Fix3
Fix shutdown logger race
2 parents 74f1fdd + f032377 commit 1e16ce1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

VRCFTPicoModule/VRCFTPicoModule.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class VRCFTPicoModule : ExtTrackingModule
2323
);
2424
private static float _eyeGainX = 1.0f;
2525
private static float _eyeGainY = 1.0f;
26+
private volatile bool _shuttingDown;
2627

2728
public override (bool SupportsEye, bool SupportsExpression) Supported => (true, true);
2829

@@ -139,17 +140,23 @@ private async Task<int> ListenOnPorts()
139140

140141
public override void Update()
141142
{
142-
_updater?.Update(Status);
143+
if (_shuttingDown) return;
144+
145+
try
146+
{
147+
_updater?.Update(Status);
148+
}
149+
catch (AggregateException ex) when (ex.InnerException is ObjectDisposedException) { }
150+
catch (ObjectDisposedException) { }
143151
}
144152

145153
public override void Teardown()
146154
{
155+
_shuttingDown = true;
156+
147157
foreach (var client in Clients)
148-
{
149158
client.Dispose();
150-
}
151159
_udpClient.Dispose();
152-
_updater = null;
153160
}
154161
private void LoadEyeGain()
155162
{

0 commit comments

Comments
 (0)