internal void WaitListenerRemoved() { ReportStack.Start(); int wakeCount = 0; lock (this) { while (wait && wakeCount < 4) { /* Made wait use a timeout in order to be able to detect * a race where sometimes the wait() doesn't return (missed event?). */ Monitor.Wait(this, 250); if (wait) { wakeCount++; /* This is either a spurious wake-up or a timeout. Unfortunately * we can't distinguish between them. */ ReportStack.Deprecated(this + ": timeout or spurious wake-up happened " + wakeCount + " times. Will " + (wakeCount < 4 ? "" : "not") + " wait again. "); } } } ReportStack.Flush(this, wakeCount > 0); }