protected void AddSourceStream(ISourceStream source_stream) { var old = Interlocked.Exchange(ref sourceStream, source_stream); if (old == null) { this.contentHeader = null; this.contents.Clear(); uptimeTimer.Restart(); } else { old.Dispose(); } sourceStream.Run().ContinueWith(prev => { RemoveSourceStream(source_stream, prev.IsFaulted ? StopReason.NotIdentifiedError : prev.Result); }); }