Exemple #1
0
        /// <summary>
        /// Run the service.
        /// </summary>
        protected override void Run()
        {
            while (true)
            {
                if ((_threadPool.QueueCount + _threadPool.ActiveCount) < _threadPool.Concurrency)
                {
                    try
                    {
                        RestoreQueue queueItem = _nasArchive.GetRestoreCandidate();

                        if (queueItem != null)
                        {
                            NasStudyRestore archiver = new NasStudyRestore(_nasArchive);
                            _threadPool.Enqueue(queueItem, archiver.Run);
                        }
                        else if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
                        {
                            Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        Platform.Log(LogLevel.Error, e, "Unexpected exception when querying for restore candidates.  Rescheduling.");
                        if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
                        {
                            Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
                            return;
                        }
                    }
                }
                else
                {
                    if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
                    {
                        Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
                        return;
                    }
                }
            }
        }
		/// <summary>
		/// Run the service.
		/// </summary>
		protected override void Run()
		{

			while (true)
			{
				if ((_threadPool.QueueCount + _threadPool.ActiveCount) < _threadPool.Concurrency)
				{
					try
					{
						RestoreQueue queueItem = _nasArchive.GetRestoreCandidate();

						if (queueItem != null)
						{
							NasStudyRestore archiver = new NasStudyRestore(_nasArchive);
							_threadPool.Enqueue(queueItem, archiver.Run);
						}
						else if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
						{
							Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
							return;
						}
					}
					catch (Exception e)
					{
						Platform.Log(LogLevel.Error, e, "Unexpected exception when querying for restore candidates.  Rescheduling.");
						if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
						{
							Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
							return;
						}
					}
				}
				else
				{
					if (CheckStop(NasSettings.Default.PollDelayMilliseconds))
					{
						Platform.Log(LogLevel.Info, "Shutting down {0} restore service.", _nasArchive.PartitionArchive.Description);
						return;
					}
				}
			}
		}