public void Close() { // Stop recording first if (this.state == RecordingState.Recording) { this.Stop(); } // Delete headers (and associated buffers) if (this.gchHeaders != null) { foreach (GCHandle gchHeader in this.gchHeaders) { this.DeleteHeader(gchHeader); } this.gchHeaders = null; } // Close wave handle if (this.hWaveIn != IntPtr.Zero) { MMInterop.waveInClose(this.hWaveIn); this.hWaveIn = IntPtr.Zero; } if (this.pwfx != IntPtr.Zero) { Marshal.FreeHGlobal(this.pwfx); this.pwfx = IntPtr.Zero; } this.output = null; this.state = RecordingState.Closed; }