private void DelayProc() { var wh = new WaitHandle[] { _evExit, _evGotDelayedNotification }; var notifications = new List <IRepositoryChangedNotification>(); while (true) { lock (_delayedNotifications) { while (_delayedNotifications.Count != 0) { notifications.Add(_delayedNotifications.Dequeue()); } } if (notifications.Count == 0) { if (WaitHandle.WaitAny(wh) == 0) { return; } continue; } switch (WaitHandle.WaitAny(wh, _notificationDelayTime)) { case 0: return; case 1: continue; case WaitHandle.WaitTimeout: WorktreeUpdatedNotification globalwtn = null; int count = 0; foreach (var n in notifications) { if (n is WorktreeUpdatedNotification wtn) { if (count == 0) { globalwtn = wtn; ++count; } else { globalwtn = new WorktreeUpdatedNotification(""); ++count; } } else { EmitNotification(n); } } notifications.Clear(); if (globalwtn != null) { EmitNotification(globalwtn); } break; } } }
private void DelayProc() { var wh = new WaitHandle[] { _evExit, _evGotDelayedNotification }; var notifications = new List<IRepositoryChangedNotification>(); while(true) { lock(_delayedNotifications) { while(_delayedNotifications.Count != 0) notifications.Add(_delayedNotifications.Dequeue()); } if(notifications.Count == 0) { if(WaitHandle.WaitAny(wh) == 0) return; continue; } switch(WaitHandle.WaitAny(wh, _notificationDelayTime)) { case 0: return; case 1: continue; case WaitHandle.WaitTimeout: WorktreeUpdatedNotification globalwtn = null; int count = 0; foreach(var n in notifications) { var wtn = n as WorktreeUpdatedNotification; if(wtn != null) { if(count == 0) { globalwtn = wtn; ++count; } else { globalwtn = new WorktreeUpdatedNotification(""); ++count; } } else { EmitNotification(n); } } notifications.Clear(); if(globalwtn != null) EmitNotification(globalwtn); break; } } }