Skip to content

Commit

Permalink
fix multi call StreamTransferHelper.WaitUntilDisconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
tqk2811 committed Feb 17, 2025
1 parent 14f292c commit d483841
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/TqkLibrary.Proxy/StreamHeplers/StreamTransferHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TqkLibrary.Proxy.StreamHeplers
{
internal class StreamTransferHelper : BaseLogger
public class StreamTransferHelper : BaseLogger
{
const int BUFFER_SIZE = 4096;

Expand Down Expand Up @@ -33,11 +33,16 @@ public StreamTransferHelper DebugName(string? firstName, string? secondName)
return this;
}

Task? _taskWork = null;
public Task WaitUntilDisconnect(CancellationToken cancellationToken = default)
{
if (_taskWork is not null)
return _taskWork;

Task task_first = FirstToSecond(cancellationToken);
Task task_second = SecondToFirst(cancellationToken);
return Task.WhenAll(task_first, task_second);
_taskWork = Task.WhenAll(task_first, task_second);
return _taskWork;
}

async Task FirstToSecond(CancellationToken cancellationToken = default)
Expand Down

0 comments on commit d483841

Please sign in to comment.