private void Execute_NoLock(Func <bool> action, IAsyncToken asyncToken, CancellationToken cancellationToken) { if (action()) { asyncToken.Dispose(); } else { _tasks.Add(_queue.ScheduleTask(() => Execute_NoLock(action, asyncToken, cancellationToken), cancellationToken)); } }
private void Execute_NoLock(Func<bool> action, IAsyncToken asyncToken, CancellationToken cancellationToken) { if (action()) { asyncToken.Dispose(); } else { _tasks.Add(_queue.ScheduleTask(() => Execute_NoLock(action, asyncToken, cancellationToken), cancellationToken)); } }
public void RegisterNotification(Func <bool> action, int delay, IAsyncToken asyncToken, CancellationToken cancellationToken = default) { Contract.Requires(delay >= 0); if (cancellationToken.IsCancellationRequested) { asyncToken?.Dispose(); return; } var current = Environment.TickCount; _workQueue.Enqueue(new PendingWork(current + delay, action, asyncToken, cancellationToken)); }
protected override async Task ExecuteAsync() { lock (_gate) { _lastToken?.Dispose(); _lastToken = null; } // wait for global operation to finish await GlobalOperationTask.ConfigureAwait(false); // update primary solution in remote host await SynchronizePrimaryWorkspaceAsync(_globalOperationCancellationSource.Token).ConfigureAwait(false); }
public WorkItem With( InvocationReasons invocationReasons, SyntaxPath currentMember, ImmutableHashSet <IIncrementalAnalyzer> analyzers, bool retry, IAsyncToken asyncToken) { // dispose old one AsyncToken.Dispose(); // create new work item return(new WorkItem( DocumentId, ProjectId, Language, InvocationReasons.With(invocationReasons), IsLowPriority, ActiveMember == currentMember ? currentMember : null, Union(analyzers), IsRetry || retry, asyncToken)); }
public void RegisterNotification(Action action, int delayInMS, IAsyncToken asyncToken, CancellationToken cancellationToken = default(CancellationToken)) { Task task; lock (_gate) { task = _queue.ScheduleTask(() => { action(); asyncToken.Dispose(); }, cancellationToken); _tasks.Add(task); } task.Wait(cancellationToken); }
public void RegisterNotification(Func <bool> action, int delay, IAsyncToken asyncToken, CancellationToken cancellationToken = default) { Debug.Assert(delay >= 0); if (cancellationToken.IsCancellationRequested) { asyncToken?.Dispose(); return; } // Assert we have some kind of foreground thread Contract.ThrowIfFalse(ThreadingContext.HasMainThread); var current = Environment.TickCount; _workQueue.Enqueue(new PendingWork(current + delay, action, asyncToken, cancellationToken)); }
public void RegisterNotification(Action action, int delay, IAsyncToken asyncToken, CancellationToken cancellationToken = default) { Debug.Assert(delay >= 0); if (cancellationToken.IsCancellationRequested) { asyncToken?.Dispose(); return; } // Assert we have some kind of foreground thread Contract.ThrowIfTrue(CurrentForegroundThreadData.Kind == ForegroundThreadDataKind.Unknown); var current = Environment.TickCount; _workQueue.Enqueue(new PendingWork(current + delay, action, asyncToken, cancellationToken)); }
private void Search(IDisposable navigateToSearch, IAsyncToken asyncToken) { var searchTasks = _solution.Projects.Select(SearchAsync).ToArray(); var whenAllTask = Task.WhenAll(searchTasks); // NOTE(cyrusn) This SafeContinueWith is *not* cancellable. We must dispose of the notifier // in order for tests to work property. Also, if we don't notify the callback that we're // done then the UI will never stop displaying the progress bar. whenAllTask.SafeContinueWith(_ => { _callback.Done(); navigateToSearch.Dispose(); asyncToken.Dispose(); }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
protected override async Task ExecuteAsync() { lock (_gate) { _lastToken?.Dispose(); _lastToken = null; } // wait for global operation to finish await GlobalOperationTask.ConfigureAwait(false); // cancel updating solution checksum if a global operation (such as loading solution, building solution and etc) has started await UpdateSolutionChecksumAsync(_globalOperationCancellationSource.Token).ConfigureAwait(false); // check whether we had bulk change that require asset synchronization if (_synchronize) { await SynchronizeAssets().ConfigureAwait(false); } }