public void Dispose()
{
if (IsPaused) Resume();
stopThread.Set();
screenThread.Join();
if (audioSource != null)
{
audioSource.StopRecording();
audioSource.DataAvailable -= AudioDataAvailable;
}
// Close writer: the remaining data is written to a file and file is closed
writer.Close();
stopThread.Close();
}
public void Pause()