public void LaunchBuildServerInfoFetchOperation() { CancelBuildStatusFetchOperation(); DisposeBuildServerAdapter(); GetBuildServerAdapter().ContinueWith((Task <IBuildServerAdapter> task) => { if (_revisions.IsDisposed) { return; } _buildServerAdapter = task.Result; UpdateUI(); if (_buildServerAdapter == null) { return; } var scheduler = NewThreadScheduler.Default; // Run this first as it (may) force start queries var runningBuildsObservable = _buildServerAdapter.GetRunningBuilds(scheduler); var fullDayObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Today - TimeSpan.FromDays(3)); var fullObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler); var fromNowObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Now); var cancellationToken = new CompositeDisposable { fullDayObservable.OnErrorResumeNext(fullObservable) .OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromMinutes(1)) .OnErrorResumeNext(fromNowObservable) .Retry() .Repeat()) .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate), runningBuildsObservable.OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromSeconds(10))) .Retry() .Repeat() .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate) }; _buildStatusCancellationToken = cancellationToken; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void LaunchBuildServerInfoFetchOperation() { ThreadHelper.ThrowIfNotOnUIThread(); CancelBuildStatusFetchOperation(); DisposeBuildServerAdapter(); ThreadHelper.JoinableTaskFactory.RunAsync( async() => { _buildServerAdapter = await GetBuildServerAdapterAsync(); await _revisions.SwitchToMainThreadAsync(); UpdateUI(); if (_buildServerAdapter == null) { return; } var scheduler = NewThreadScheduler.Default; // Run this first as it (may) force start queries var runningBuildsObservable = _buildServerAdapter.GetRunningBuilds(scheduler); var fullDayObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Today - TimeSpan.FromDays(3)); var fullObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler); var fromNowObservable = _buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Now); var cancellationToken = new CompositeDisposable { fullDayObservable.OnErrorResumeNext(fullObservable) .OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromMinutes(1)) .OnErrorResumeNext(fromNowObservable) .Retry() .Repeat()) .ObserveOn(MainThreadScheduler.Instance) .Subscribe(OnBuildInfoUpdate), runningBuildsObservable.OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromSeconds(10))) .Retry() .Repeat() .ObserveOn(MainThreadScheduler.Instance) .Subscribe(OnBuildInfoUpdate) }; _buildStatusCancellationToken = cancellationToken; }); }
public void LaunchBuildServerInfoFetchOperation() { CancelBuildStatusFetchOperation(); DisposeBuildServerAdapter(); // Extract the project name from the last part of the directory path. It is assumed that it matches the project name in the CI build server. GetBuildServerAdapter().ContinueWith((Task <IBuildServerAdapter> task) => { if (revisions.IsDisposed) { return; } buildServerAdapter = task.Result; UpdateUI(); if (buildServerAdapter == null) { return; } var scheduler = NewThreadScheduler.Default; var fullDayObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Today - TimeSpan.FromDays(3)); var fullObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler); var fromNowObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Now); var runningBuildsObservable = buildServerAdapter.GetRunningBuilds(scheduler); var cancellationToken = new CompositeDisposable { fullDayObservable.OnErrorResumeNext(fullObservable) .OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromMinutes(1)) .OnErrorResumeNext(fromNowObservable) .Retry() .Repeat()) .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate), runningBuildsObservable.OnErrorResumeNext(Observable.Empty <BuildInfo>() .DelaySubscription(TimeSpan.FromSeconds(10))) .Retry() .Repeat() .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate) }; buildStatusCancellationToken = cancellationToken; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void LaunchBuildServerInfoFetchOperation() { CancelBuildStatusFetchOperation(); DisposeBuildServerAdapter(); // Extract the project name from the last part of the directory path. It is assumed that it matches the project name in the CI build server. GetBuildServerAdapter().ContinueWith((Task<IBuildServerAdapter> task) => { if (revisions.IsDisposed) { return; } buildServerAdapter = task.Result; UpdateUI(); if (buildServerAdapter == null) return; var scheduler = NewThreadScheduler.Default; var fullDayObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Today - TimeSpan.FromDays(3)); var fullObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler); var fromNowObservable = buildServerAdapter.GetFinishedBuildsSince(scheduler, DateTime.Now); var runningBuildsObservable = buildServerAdapter.GetRunningBuilds(scheduler); var cancellationToken = new CompositeDisposable { fullDayObservable.OnErrorResumeNext(fullObservable) .OnErrorResumeNext(Observable.Empty<BuildInfo>() .DelaySubscription(TimeSpan.FromMinutes(1)) .OnErrorResumeNext(fromNowObservable) .Retry() .Repeat()) .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate), runningBuildsObservable.OnErrorResumeNext(Observable.Empty<BuildInfo>() .DelaySubscription(TimeSpan.FromSeconds(10))) .Retry() .Repeat() .ObserveOn(SynchronizationContext.Current) .Subscribe(OnBuildInfoUpdate) }; buildStatusCancellationToken = cancellationToken; }, TaskScheduler.FromCurrentSynchronizationContext()); }