public void StopListening() { if (rtpStream != null) { rtpStream.FrameReceived -= new RtpStream.FrameReceivedEventHandler(FrameReceived); this.rtpStream = null; } int curIndex = curBufIndex; if (buffers != null) { do { BufferManager buf = buffers[curBufIndex]; perfCounter.RemoveInstanceForCollection(buf); buf.Dispose(); curBufIndex = (curBufIndex + 1) % bufferCount; }while (curBufIndex != curIndex); this.buffers = null; } }