Skip to content

Commit

Permalink
Wrong way of using of TaskCreationOptions.LongRunning
Browse files Browse the repository at this point in the history
  • Loading branch information
luboid authored and shubhamranjan committed Aug 4, 2024
1 parent 72315fe commit 12adafa
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions dotnet-etcd/leaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Task LeaseKeepAlive(CancellationTokenSource cancellationTokenSource, long
}
CancellationToken cancellationToken = cancellationTokenSource.Token;
int communicationTimeoutInMilliseconds = communicationTimeout ?? keepAliveTimeout / 2;
async ValueTask WriteAsync(AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> leaser, LeaseKeepAliveRequest request, int timeoutInMilliseconds, CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -125,9 +126,8 @@ AsyncDuplexStreamingCall<LeaseKeepAliveRequest, LeaseKeepAliveResponse> LeaseKee
return connection.LeaseClient.LeaseKeepAlive(headers, deadline, cancellationTokenSource.Token);
}
async Task KeepAliveAsync(object state)
async Task KeepAliveAsync()
{
int communicationTimeoutInMilliseconds = communicationTimeout ?? keepAliveTimeout / 2;
LeaseKeepAliveRequest request = new()
{
ID = leaseId,
Expand Down Expand Up @@ -210,13 +210,7 @@ await cancellationTokenSource.CancelAsync()
}
}
return Task.Factory.StartNew(
KeepAliveAsync,
null,
cancellationToken,
TaskCreationOptions.LongRunning,
TaskScheduler.Current)
.Unwrap();
return Task.Run(KeepAliveAsync, cancellationToken);
});

/// <summary>
Expand Down

0 comments on commit 12adafa

Please sign in to comment.