private Connection(string pipeName, IProfilerControl profilerControl)
        {
            mPipeName        = pipeName;
            mProfilerControl = profilerControl;

            mIncomingRawMessageStreams = new BehaviorSubject <IObservable <byte[]> >(Observable.Empty <byte[]>());
            var whenConnected = new Subject <bool>();

            var incomingMessages = mIncomingRawMessageStreams
                                   .Select(stream => Observable.Defer(() =>
            {
                whenConnected.OnNext(true);
                return(stream.Finally(() => whenConnected.OnNext(false)));
            }))
                                   .Switch()
                                   .Select(Protocol.EventMessage.Parser.ParseFrom);

            ModelUpdateSource = new ModelUpdateSource(incomingMessages);
            WhenConnected     = whenConnected.Publish(false).ConnectForEver();
        }
 public static Connection Create(string pipeName, IProfilerControl profilerControl)
 {
     return(new Connection(pipeName, profilerControl));
 }