Пример #1
0
 private void SendNotificationToAllClients(FileEventArgs e)
 {
     foreach (var client in _clients)
     {
         // Create a new thread for each client in order to send the notification
         ThreadPool.QueueUserWorkItem(NotifyThreadProc, NotifyThreadStateInfo.Create(client.Value, e));
     }
 }
Пример #2
0
        private void NotifyThreadProc(object state)
        {
            NotifyThreadStateInfo stateInfo = state as NotifyThreadStateInfo;

            if (stateInfo == null)
            {
                return;
            }

            try
            {
                Logger.WriteToLog(String.Format("[NotifyThreadPool] Notifying client with GUID: '{0}', Info: '{1}', Status: '{2}'",
                                                stateInfo.Client.Id, stateInfo.Args.FileName, FileAnalysisStatusExtension.ToString(stateInfo.Args.AnalysisStatus)));
                stateInfo.Client.Callback.OnSentNotification(stateInfo.Args);
            }
            catch (TimeoutException)
            {
                Logger.WriteToLog(String.Format("TimeoutException. Invalidating client with GUID: '{0}'.", stateInfo.Client.Id));
                stateInfo.Client.Invalidate();
            }
        }