public void WaitForStop() { if (thread != null) { for (int i = 0; i < notifications.Length; i++) (notifications[i].WaitHandle as AutoResetEvent).Set(); // wait for thread stop thread.Join(); thread = null; } }