public void AddThread(AddressIdentifier clientAddressIdentifier, ConnectionSessionId id) { var clientAddress = new Address(new TcpIpProtocol(), clientAddressIdentifier); var notificationQueue = new TimeoutBlockingQueue <NotificationObject>(1000); var notificationThread = new NotificationThread(zmqContext, clientAddress, id, notificationQueue); notificationThreads.Add(id, notificationThread); notificationQueues.Add(id, notificationQueue); new Thread(notificationThread.Run).Start(); }
// Entry point for the Scrobbler. Accepts the API client and user interfaces instances in use. public static async Task Initialize(LastFMClient lastFMClient, NotificationThread uiThread, string logFilePathAndFilename) { _uiThread = uiThread; _lastFMClient = lastFMClient; _logFilePathAndFilename = logFilePathAndFilename; // Initialize the plugins, irrespective of enabled state foreach (IScrobbleSource source in ScrobblePlugins) { source.InitializeSource(MinimumScrobbleSeconds, ScrobbleSource_OnTrackMonitoringStarted, Scrobble_OnTrackMonitoring, ScrobbleSource_OnTrackMonitoringEnded, ScrobbleSource_OnScrobbleTrack); } _isInitialized = true; }
private void RunNotificationThread(ConnectionSessionId connectionSessionId) { notificationThread = new NotificationThread(zmqContext, ClientAddress, connectionSessionId); notificationThread.NewDomainEventAvailable += OnNewDomainEventAvailable; notificationThread.NewPatientAvailable += OnNewPatientAvailable; notificationThread.UpdatedPatientAvailable += OnUpdatedPatientAvailable; notificationThread.NewTherapyPlaceTypeAvailable += OnNewTherapyPlaceTypeAvailable; notificationThread.UpdatedTherapyPlaceTypeAvailable += OnUpdatedTherapyPlaceTypeAvailable; notificationThread.NewLabelAvailable += OnNewLabelAvailable; notificationThread.UpdatedLabelAvailable += OnUpdatedLabelAvailable; new Thread(notificationThread.Run).Start(); }
private void StopNotificationThread() { if (notificationThread != null) { notificationThread.NewDomainEventAvailable -= OnNewDomainEventAvailable; notificationThread.NewPatientAvailable -= OnNewPatientAvailable; notificationThread.UpdatedPatientAvailable -= OnUpdatedPatientAvailable; notificationThread.NewTherapyPlaceTypeAvailable -= OnNewTherapyPlaceTypeAvailable; notificationThread.UpdatedTherapyPlaceTypeAvailable -= OnUpdatedTherapyPlaceTypeAvailable; notificationThread.NewLabelAvailable -= OnNewLabelAvailable; notificationThread.UpdatedLabelAvailable -= OnUpdatedLabelAvailable; notificationThread.Stop(); notificationThread = null; } }