public Task onElectionEvent(ElectionEventType eventType)
 {
     if (eventType == ElectionEventType.ELECTED_COMPLETE)
     {
         if (ElectionComplted != null)
         {
             return(ElectionComplted());
         }
     }
     return(Task.CompletedTask);
 }
Esempio n. 2
0
        private async Task dispatchEvent(ElectionEventType eventType)
        {
            logger.debugFormat("Dispatching event:{0}", eventType);

            using (await listenersLock.LockAsync().ConfigureAwait(false)) {
                if (listeners.Count > 0)
                {
                    foreach (var observer in listeners.Keys)
                    {
                        try {
                            await observer.onElectionEvent(eventType).ConfigureAwait(false);
                        }
                        catch (Exception e) {
                            logger.warn("error while calling observer", e);
                        }
                    }
                }
            }
        }