当前位置: 首页>>代码示例>>C#>>正文


C# IAsyncToken类代码示例

本文整理汇总了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));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:8,代码来源:ForegroundNotificationService.cs

示例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)
 {
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:WorkCoordinator.WorkItem.cs

示例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);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:10,代码来源:TaskExtensions.cs

示例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);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:11,代码来源:TestForegroundNotificationService.cs

示例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));
     }
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:11,代码来源:TestForegroundNotificationService.cs

示例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);
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:18,代码来源:NavigateToItemProvider.Searcher.cs

示例7: PendingWork

 public PendingWork(int minimumRunPointInMS, Action work, IAsyncToken asyncToken, CancellationToken cancellationToken)
     : this(minimumRunPointInMS, work, null, asyncToken, cancellationToken)
 {
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:4,代码来源:ForegroundNotificationService.cs

示例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);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:6,代码来源:WorkCoordinator.cs

示例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);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:6,代码来源:WorkCoordinator.WorkItem.cs

示例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;
                }
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:34,代码来源:WorkCoordinator.cs

示例11: EnqueueEvent

 private void EnqueueEvent(Solution solution, InvocationReasons invocationReasons, IAsyncToken asyncToken)
 {
     var task = _eventProcessingQueue.ScheduleTask(
         () => EnqueueWorkItemForSolution(solution, invocationReasons), _shutdownToken).CompletesAsyncOperation(asyncToken);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:5,代码来源:WorkCoordinator.cs

示例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;
                }
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:27,代码来源:WorkCoordinator.cs

示例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;
     }
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:22,代码来源:WorkCoordinator.cs

示例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);
            }
开发者ID:lachbaer,项目名称:roslyn,代码行数:14,代码来源:RemoteHostClientServiceFactory.SolutionChecksumUpdater.cs

示例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);
                }
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:20,代码来源:RemoteHostClientServiceFactory.SolutionChecksumUpdater.cs


注:本文中的IAsyncToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。