Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
/// </summary>
public class LengthPrefixCommunicationChannel : ICommunicationChannel
{

private const int NoSubscriberTimeoutMs = 100;

private readonly BinaryReader _reader;

private readonly BinaryWriter _writer;
Expand Down Expand Up @@ -87,6 +90,11 @@ public Task NotifyDataAvailable()
// connection is closed.
if (MessageReceived != null)
{
if (MessageReceived.GetInvocationList().Length == 0)
{
Task.Delay(NoSubscriberTimeoutMs);
}

var data = _reader.ReadString();
MessageReceived.SafeInvoke(this, new MessageReceivedEventArgs { Data = data }, "LengthPrefixCommunicationChannel: MessageReceived");
}
Expand Down