/// <summary> /// Execute the service. /// </summary> protected override void Run() { while (true) { if ((_threadPool.QueueCount + _threadPool.ActiveCount) < _threadPool.Concurrency) { try { ArchiveQueue queueItem = _nasArchive.GetArchiveCandidate(); if (queueItem != null) { NasStudyArchive archiver = new NasStudyArchive(_nasArchive); _threadPool.Enqueue(queueItem, archiver.Run); } else if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unexpected exception when querying for archive candidates, rescheduling."); if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } } else { if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } } }
/// <summary> /// Execute the service. /// </summary> protected override void Run() { while (true) { if ((_threadPool.QueueCount + _threadPool.ActiveCount) < _threadPool.Concurrency) { try { ArchiveQueue queueItem = _nasArchive.GetArchiveCandidate(); if (queueItem != null) { NasStudyArchive archiver = new NasStudyArchive(_nasArchive); _threadPool.Enqueue(queueItem, archiver.Run); } else if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } catch (Exception e) { Platform.Log(LogLevel.Error,e,"Unexpected exception when querying for archive candidates, rescheduling."); if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } } else { if (CheckStop(NasSettings.Default.PollDelayMilliseconds)) { Platform.Log(LogLevel.Info, "Shutting down {0} archiving service.", _nasArchive.PartitionArchive.Description); return; } } } }