Skip to content

Commit 62841e4

Browse files
committed
Fix semaphore release
1 parent e085ef6 commit 62841e4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Shiny.Locations/GpsDelegate.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ public abstract class GpsDelegate(ILogger logger) : NotifyPropertyChanged, IGpsD
1414

1515
public async Task OnReading(GpsReading reading)
1616
{
17+
var entered = false;
1718
try
1819
{
1920
await this.semaphore.WaitAsync().ConfigureAwait(false);
21+
entered = true;
2022
if (this.DetectStationary)
2123
this.DetectIfStationary(reading);
2224

@@ -60,7 +62,8 @@ public async Task OnReading(GpsReading reading)
6062
}
6163
finally
6264
{
63-
this.semaphore.Release();
65+
if (entered)
66+
this.semaphore.Release();
6467
}
6568
}
6669

0 commit comments

Comments
 (0)