public Form1() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; player = new NAudioPlayer(); player.OnPeak += Player_OnPeak; FormClosing += (obj, args) => { player?.Dispose(); }; }