Internal method to dequeue to events.

def _dequeue_function(self):
		""" Internal method to dequeue to events. """
		from UcsBase import WriteUcsWarning, _GenericMO, WriteObject, UcsUtils

		while len(self._wbs):
			lowestTimeout = None
			for wb in self._wbs:
				pollSec = wb.params["pollSec"]
				managedObject = wb.params["managedObject"]
				timeoutSec = wb.params["timeoutSec"]
				transientValue = wb.params["transientValue"]
				successValue = wb.params["successValue"]
				failureValue = wb.params["failureValue"]
				prop = wb.params["prop"]
				startTime = wb.params["startTime"]

				gmo = None
				pmo = None
				mce = None

				if (pollSec != None and managedObject != None):
					crDn = self.ConfigResolveDn(managedObject.getattr("Dn"), inHierarchical=YesOrNo.FALSE,
												dumpXml=YesOrNo.FALSE)
					if (crDn.errorCode != 0):
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning(
							'[Error]: WatchUcs [Code]:' + crDn.errorCode + ' [Description]:' + crDn.errorDescr)
						continue

					for eachMo in crDn.OutConfig.GetChild():
						pmo = eachMo
					if pmo == None:
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning('Mo ' + managedObject.getattr("Dn") + ' not found.')
						continue

					gmo = _GenericMO(mo=pmo, option=WriteXmlOption.All)
				else:
					ts = datetime.datetime.now() - startTime
					timeoutMs = 0
					if (timeoutSec != None):
						if (ts.seconds >= timeoutSec):  # TimeOut
							self._remove_watch_block(wb)
							continue
						timeoutMs = (timeoutSec - ts.seconds)

						if (lowestTimeout == None):
							lowestTimeout = timeoutMs
						else:
							if (lowestTimeout > timeoutMs):
								lowestTimeout = timeoutMs

					if (timeoutMs > 0):
						mce = wb.Dequeue(timeoutMs)
					else:
						mce = wb.Dequeue(2147483647)
					if mce == None:
						# break
						continue

				if (managedObject == None):  # Means parameterset is not Mo
					if wb.cb != None:
						wb.cb(mce)
					continue

				if mce != None:
					gmo = _GenericMO(mo=mce.mo, option=WriteXmlOption.All)

				attributes = []
				if mce == None:
					attributes = gmo.properties.keys()
				else:
					attributes = mce.changeList
				if prop.lower() in (attr.lower() for attr in attributes):
					if (len(successValue) > 0 and gmo.GetAttribute(UcsUtils.WordU(prop)) in successValue):
						if mce != None:
							if wb.cb != None:
								wb.cb(mce)
						else:
							if wb.cb != None:
								wb.cb(UcsMoChangeEvent(eventId=0, mo=pmo, changeList=prop))

						if wb != None:
							self._remove_watch_block(wb)
							wb = None
							break

						# return
						continue
					if (len(failureValue) > 0 and gmo.GetAttribute(UcsUtils.WordU(prop)) in failureValue):
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning('Encountered error value ' + gmo.GetAttribute(
							UcsUtils.WordU(prop)) + ' for property ' + prop + '.')
						if mce != None:
							if wb.cb != None:
								wb.cb(mce)
						else:
							if wb.cb != None:
								wb.cb(UcsMoChangeEvent(eventId=0, mo=pmo, changeList=prop))

						if wb != None:
							self._remove_watch_block(wb)  # TODO: implement removeStop call back
							wb = None
							break

						continue
					if ((len(transientValue) > 0) and (not gmo.GetAttribute(UcsUtils.WordU(prop)) in transientValue)):
						# TODO: Add Warning/Error messages in Logger.
						WriteUcsWarning('Encountered unknown value ' + gmo.GetAttribute(
							UcsUtils.WordU(prop)) + ' for property ' + prop + '.')
						if mce != None:
							if wb.cb != None:
								wb.cb(mce)
						else:
							if wb.cb != None:
								wb.cb(UcsMoChangeEvent(eventId=0, mo=pmo, changeList=prop))

						if wb != None:
							self._remove_watch_block(wb)  # TODO: implement removeStop call back
							wb = None
							break

						continue

				if (pollSec != None):
					pollMs = pollSec
					if (timeoutSec != None):
						pts = datetime.datetime.now() - startTime
						if (pts.seconds >= timeoutSec):  # TimeOut
							break
						timeoutMs = (timeoutSec - pts.seconds)

						if (timeoutMs < pollSec):
							pollMs = pts.seconds

					# time.sleep(pollMs)
					if (lowestTimeout == None):
						lowestTimeout = pollMs
					else:
						if (lowestTimeout > pollMs):
							lowestTimeout = pollMs

			if len(self._wbs):
				self._dequeue_wait(lowestTimeout)
		return