Skip to content

Commit

Permalink
Refinement to concurrency section of readme
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Sep 27, 2018
1 parent 2a9776d commit 3fc5ad8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ The `MsBuildPipeLogger.Logger` recognizes these parameters, separated by a `;` a

### A note on concurrency

The `AnonymousPipeLoggerServer.Read()` and `NamedPipeLoggerServer.Read()` methods both block while waiting for additional events. If you need to support concurrency or cancellation, you'll need to wrap this call however is appropriate for your application.
The `AnonymousPipeLoggerServer.Read()` and `NamedPipeLoggerServer.Read()` methods both block while waiting for events. If you need to support concurrency or cancellation, pass a `CancellationToken` to the server constructors and then cancel it during read operations.

6 changes: 3 additions & 3 deletions src/MsBuildPipeLogger.Server/NamedPipeLoggerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace MsBuildPipeLogger
/// </summary>
public class NamedPipeLoggerServer : PipeLoggerServer<NamedPipeServerStream>
{
private readonly InterlockedBool _connected = new InterlockedBool(false);

public string PipeName { get; }

/// <summary>
Expand Down Expand Up @@ -38,9 +40,7 @@ protected override void Connect()
PipeStream.WaitForConnection();
_connected.Set();
}

private readonly InterlockedBool _connected = new InterlockedBool(false);


private void CancelConnectionWait()
{
if(!_connected.Set())
Expand Down

0 comments on commit 3fc5ad8

Please sign in to comment.