bool StartUpdateProcessor(TimeSpan maxWaitTime) { var initTask = updateProcessor.Start(); try { return(initTask.Wait(maxWaitTime)); } catch (AggregateException e) { throw UnwrapAggregateException(e); } }
// This method is called while _lock is being held. If we're starting up a new connection, we do // *not* wait for it to succeed; we return a Task that will be completed once it succeeds. In all // other cases we return an immediately-completed Task. private Task <bool> OpenOrCloseConnectionIfNecessary() { if (!_started) { return(Task.FromResult(false)); } if (_networkEnabled && !_forceOffline) { if (_updateProcessor == null && _updateProcessorFactory != null) { _updateProcessor = _updateProcessorFactory(); return(_updateProcessor.Start() .ContinueWith(SetInitializedIfUpdateProcessorStartedSuccessfully)); } } else { _updateProcessor?.Dispose(); _updateProcessor = null; _initialized = true; return(Task.FromResult(true)); } return(Task.FromResult(false)); }