Example #1
0
		protected override void Stop()
		{
			if (_theProcessor != null)
			{
				_theProcessor.Stop();
				_theProcessor = null;
			}
		}
		protected override bool Initialize()
		{
			if (_theProcessor == null)
			{
				// Force a read context to be opened.  When developing the retry mechanism 
				// for startup when the DB was down, there were problems when the type
				// initializer for enumerated values were failng first.  For some reason,
				// when the database went back online, they would still give exceptions.
				// changed to force the processor to open a dummy DB connect and cause an 
				// exception here, instead of getting to the enumerated value initializer.
				using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
				{
				}

				_theProcessor = new ServiceLockProcessor(2, ThreadStop); // 2 threads for processor
			}

            return true;
		}
		protected override void Stop()
		{
			//TODO CR (Jan 2014): Move this into the base if it applies to all subclasses?
			PersistentStoreRegistry.GetDefaultStore().ShutdownRequested = true;

			if (_theProcessor != null)
			{
				_theProcessor.Stop();
				_theProcessor = null;
			}
		}