Exemplo n.º 1
0
        protected void ParseModule(QualifiedModuleName module, CancellationToken token)
        {
            _state.ClearStateCache(module);
            var finishedParseTask = FinishedParseComponentTask(module, token);

            ProcessComponentParseResults(module, finishedParseTask, token);
        }
Exemplo n.º 2
0
        public Task ParseAsync(VBComponent component, CancellationToken token, TokenStreamRewriter rewriter = null)
        {
            lock (_state)
                lock (component)
                {
                    _state.ClearStateCache(component);
                    _state.SetModuleState(component, ParserState.Pending); // also clears module-exceptions
                }

            var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_central.Token, token);

            var task = new Task(() => ParseAsyncInternal(component, linkedTokenSource.Token, rewriter));

            _currentTasks.TryAdd(component, Tuple.Create(task, linkedTokenSource));

            Tuple <Task, CancellationTokenSource> removedTask;

            task.ContinueWith(t => _currentTasks.TryRemove(component, out removedTask)); // default also executes on cancel
            // See http://stackoverflow.com/questions/6800705/why-is-taskscheduler-current-the-default-taskscheduler
            task.Start(TaskScheduler.Default);
            return(task);
        }