/// <summary> /// Starts monitoring table's content changes. /// </summary> /// <param name="timeOut">The WAITFOR timeout in seconds.</param> /// <param name="watchDogTimeOut">The WATCHDOG timeout in seconds.</param> /// <returns></returns> public override void Start(int timeOut = 120, int watchDogTimeOut = 180) { if (timeOut < 60) { throw new ArgumentException("timeOut must be greater or equal to 60 seconds"); } if (watchDogTimeOut < 60 || watchDogTimeOut < (timeOut + 60)) { throw new WatchDogTimeOutException("watchDogTimeOut must be at least 60 seconds bigger then timeOut"); } if (_task != null) { return; } if (OnChanged == null) { throw new NoSubscriberException(); } var onChangedSubscribedList = OnChanged?.GetInvocationList(); var onErrorSubscribedList = OnError?.GetInvocationList(); var onStatusChangedSubscribedList = OnStatusChanged?.GetInvocationList(); NotifyListenersAboutStatus(onStatusChangedSubscribedList, TableDependencyStatus.Starting); _disposed = false; CreateOrReuseConversation(timeOut, watchDogTimeOut); _cancellationTokenSource = new CancellationTokenSource(); _task = Task.Factory.StartNew(() => WaitForNotifications( _cancellationTokenSource.Token, onChangedSubscribedList, onErrorSubscribedList, onStatusChangedSubscribedList, timeOut, watchDogTimeOut), _cancellationTokenSource.Token); WriteTraceMessage(TraceLevel.Info, "Waiting for receiving " + _tableName + "'s records change notifications.", (Exception)null); }