public void OnError(Exception error) { if (System.Threading.Interlocked.Increment(ref isStopped) == 1) { parent.lastException = error; var p = parent.publisher; if (p != null) { p.OnError(error); } parent.Dispose(); // complete subscription } }