本文整理汇总了C#中IAsyncToken类的典型用法代码示例。如果您正苦于以下问题:C# IAsyncToken类的具体用法?C# IAsyncToken怎么用?C# IAsyncToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAsyncToken类属于命名空间,在下文中一共展示了IAsyncToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterNotification
public void RegisterNotification(Func<bool> action, int delay, IAsyncToken asyncToken, CancellationToken cancellationToken = default(CancellationToken))
{
Contract.Requires(delay >= 0);
var current = Environment.TickCount;
_workQueue.Enqueue(new PendingWork(current + delay, action, asyncToken, cancellationToken));
}
示例2: WorkItem
public WorkItem(
DocumentId documentId, string language, InvocationReasons invocationReasons, bool isLowPriority,
SyntaxPath activeMember, IAsyncToken asyncToken)
: this(documentId, documentId.ProjectId, language, invocationReasons, isLowPriority,
activeMember, ImmutableHashSet.Create<IIncrementalAnalyzer>(),
false, asyncToken)
{
}
示例3: CompletesAsyncOperation
public static Task CompletesAsyncOperation(this Task task, IAsyncToken asyncToken)
{
var diagnosticToken = asyncToken as AsynchronousOperationListener.DiagnosticAsyncToken;
if (diagnosticToken != null)
{
diagnosticToken.AssociateWithTask(task);
}
return task.CompletesTrackingOperation(asyncToken);
}
示例4: RegisterNotification
public void RegisterNotification(Func<bool> action, int delayInMS, IAsyncToken asyncToken, CancellationToken cancellationToken = default(CancellationToken))
{
Task task;
lock (_gate)
{
task = _queue.ScheduleTask(() => Execute_NoLock(action, asyncToken, cancellationToken), cancellationToken);
_tasks.Add(task);
}
task.Wait(cancellationToken);
}
示例5: Execute_NoLock
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));
}
}
示例6: Search
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);
}
示例7: PendingWork
public PendingWork(int minimumRunPointInMS, Action work, IAsyncToken asyncToken, CancellationToken cancellationToken)
: this(minimumRunPointInMS, work, null, asyncToken, cancellationToken)
{
}
示例8: EnqueueEvent
private void EnqueueEvent(Solution oldSolution, Solution newSolution, DocumentId documentId, IAsyncToken asyncToken)
{
// document changed event is the special one.
_eventProcessingQueue.ScheduleTask(
() => EnqueueWorkItemAfterDiffAsync(oldSolution, newSolution, documentId), _shutdownToken).CompletesAsyncOperation(asyncToken);
}
示例9: With
public WorkItem With(IAsyncToken asyncToken)
{
return new WorkItem(
this.DocumentId, this.ProjectId, this.Language, this.InvocationReasons, this.IsLowPriority, this.ActiveMember, this.Analyzers,
retry: false, asyncToken: asyncToken);
}
示例10: ProcessEvents
private void ProcessEvents(WorkspaceChangeEventArgs args, IAsyncToken asyncToken)
{
SolutionCrawlerLogger.LogWorkspaceEvent(_logAggregator, (int)args.Kind);
// TODO: add telemetry that record how much it takes to process an event (max, min, average and etc)
switch (args.Kind)
{
case WorkspaceChangeKind.SolutionAdded:
case WorkspaceChangeKind.SolutionChanged:
case WorkspaceChangeKind.SolutionReloaded:
case WorkspaceChangeKind.SolutionRemoved:
case WorkspaceChangeKind.SolutionCleared:
ProcessSolutionEvent(args, asyncToken);
break;
case WorkspaceChangeKind.ProjectAdded:
case WorkspaceChangeKind.ProjectChanged:
case WorkspaceChangeKind.ProjectReloaded:
case WorkspaceChangeKind.ProjectRemoved:
ProcessProjectEvent(args, asyncToken);
break;
case WorkspaceChangeKind.DocumentAdded:
case WorkspaceChangeKind.DocumentReloaded:
case WorkspaceChangeKind.DocumentChanged:
case WorkspaceChangeKind.DocumentRemoved:
case WorkspaceChangeKind.AdditionalDocumentAdded:
case WorkspaceChangeKind.AdditionalDocumentRemoved:
case WorkspaceChangeKind.AdditionalDocumentChanged:
case WorkspaceChangeKind.AdditionalDocumentReloaded:
ProcessDocumentEvent(args, asyncToken);
break;
default:
throw ExceptionUtilities.Unreachable;
}
}
示例11: EnqueueEvent
private void EnqueueEvent(Solution solution, InvocationReasons invocationReasons, IAsyncToken asyncToken)
{
var task = _eventProcessingQueue.ScheduleTask(
() => EnqueueWorkItemForSolution(solution, invocationReasons), _shutdownToken).CompletesAsyncOperation(asyncToken);
}
示例12: ProcessDocumentEvent
private void ProcessDocumentEvent(WorkspaceChangeEventArgs e, IAsyncToken asyncToken)
{
switch (e.Kind)
{
case WorkspaceChangeKind.DocumentAdded:
EnqueueEvent(e.NewSolution, e.DocumentId, InvocationReasons.DocumentAdded, asyncToken);
break;
case WorkspaceChangeKind.DocumentRemoved:
EnqueueEvent(e.OldSolution, e.DocumentId, InvocationReasons.DocumentRemoved, asyncToken);
break;
case WorkspaceChangeKind.DocumentReloaded:
case WorkspaceChangeKind.DocumentChanged:
EnqueueEvent(e.OldSolution, e.NewSolution, e.DocumentId, asyncToken);
break;
case WorkspaceChangeKind.AdditionalDocumentAdded:
case WorkspaceChangeKind.AdditionalDocumentRemoved:
case WorkspaceChangeKind.AdditionalDocumentChanged:
case WorkspaceChangeKind.AdditionalDocumentReloaded:
// If an additional file has changed we need to reanalyze the entire project.
EnqueueEvent(e.NewSolution, e.ProjectId, InvocationReasons.AdditionalDocumentChanged, asyncToken);
break;
default:
throw ExceptionUtilities.Unreachable;
}
}
示例13: ProcessSolutionEvent
private void ProcessSolutionEvent(WorkspaceChangeEventArgs e, IAsyncToken asyncToken)
{
switch (e.Kind)
{
case WorkspaceChangeKind.SolutionAdded:
OnSolutionAdded(e.NewSolution);
EnqueueEvent(e.NewSolution, InvocationReasons.DocumentAdded, asyncToken);
break;
case WorkspaceChangeKind.SolutionRemoved:
EnqueueEvent(e.OldSolution, InvocationReasons.SolutionRemoved, asyncToken);
break;
case WorkspaceChangeKind.SolutionCleared:
EnqueueEvent(e.OldSolution, InvocationReasons.DocumentRemoved, asyncToken);
break;
case WorkspaceChangeKind.SolutionChanged:
case WorkspaceChangeKind.SolutionReloaded:
EnqueueEvent(e.OldSolution, e.NewSolution, asyncToken);
break;
default:
throw ExceptionUtilities.Unreachable;
}
}
示例14: SynchronizePrimaryWorkspaceAsync
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);
}
示例15: UpdateSolutionChecksumAsync
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);
}
}