Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 fix websocket pinger start #91

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions SurrealDb.Net/Internals/Ws/Pinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public Pinger(Func<CancellationToken, Task> pingCallback)
public void Start()
{
#if NET5_0_OR_GREATER
if (_timerTask is not null)
if (_timerTask is null)
{
_cancellationTokenSource = new();
_timerTask = ExecuteAsync();
}
#else
if (_timer != null)
if (_timer is null)
{
_timer = new(Execute, null, TimeSpan.Zero, _timerInterval);
}
Expand All @@ -37,9 +37,14 @@ public void Start()
public void Dispose()
{
#if NET5_0_OR_GREATER
_timerTask?.Dispose();
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();
if (_cancellationTokenSource is not null)
{
if (!_cancellationTokenSource.IsCancellationRequested)
{
_cancellationTokenSource?.Cancel();
}
_cancellationTokenSource?.Dispose();
}
#endif
_timer?.Dispose();
}
Expand Down
Loading