Skip to content

Commit 62f1d6f

Browse files
committed
Update PemStream.InnerReadAsync() cancellation
.NET 7 and up have native cancellation support in StreamReader.ReadLineAsync(), while .NET 6 has the Task.WaitAsync(CancellationToken) api we can alternatively use (and we don't support cancellation for lower versions).
1 parent ee562b8 commit 62f1d6f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

SecureStore/PemStream.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ private async Task<byte[]> InnerReadAsync(Stream stream, Func<StreamReader, Task
6565

6666
public async Task<byte[]> ReadAsync(Stream stream, CancellationToken cancel = default)
6767
{
68-
#if NET6_0_OR_GREATER
68+
#if NET7_0_OR_GREATER
69+
return await InnerReadAsync(stream, async (reader) => await reader.ReadLineAsync(cancel));
70+
#elif NET6_0_OR_GREATER
6971
return await InnerReadAsync(stream, async (reader) => await reader.ReadLineAsync().WaitAsync(cancel));
7072
#else
7173
return await InnerReadAsync(stream, async (reader) => await reader.ReadLineAsync());

0 commit comments

Comments
 (0)