Ejemplo n.º 1
0
        static void noticeFinish(ParseIntermediate p)
        {
            var im = p.im;

            im.sw.Stop();
            im.completed.Set();

            if (!string.IsNullOrEmpty(p.im.basePath) && p.root != null)
            {
                ParsedDirectories [im.basePath] = p.root;
                p.root.TryPreResolveCommonTypes();
            }

            var pf = new ParsingFinishedEventArgs(im.basePath, p.root, im.actualTimeNeeded, im.ActualParseTimeNeeded, im.totalFiles);

            if (ParseTaskFinished != null)
            {
                ParseTaskFinished(pf);
            }

            criticalPreparationSection.WaitOne();
            var subTasks = im.parseSubTasksUntilFinished.ToArray();

            if (p.im.basePath != null)
            {
                ParseStatistics.Remove(p.im.basePath);
            }

            criticalPreparationSection.Set();

            foreach (var subtask in subTasks)
            {
                if (Interlocked.Decrement(ref subtask.i) < 1 && subtask.finishedHandler != null)
                {
                    subtask.finishedHandler(pf);                      // Generic issue: The wrong statistics will be passed, if we fire the event for a task which was added some time afterwards
                }
            }

            if (Interlocked.Decrement(ref parsingThreads) <= 0)
            {
                parseCompletedEvent.Set();
            }
        }
Ejemplo n.º 2
0
		static void noticeFinish (ParseIntermediate p)
		{
			var im = p.im;

			im.sw.Stop ();
			im.completed.Set ();

			if (!string.IsNullOrEmpty (p.im.basePath) && p.root != null) {
				ParsedDirectories [im.basePath] = p.root;
				p.root.TryPreResolveCommonTypes ();
			}

			var pf = new ParsingFinishedEventArgs (im.basePath, p.root, im.actualTimeNeeded, im.ActualParseTimeNeeded, im.totalFiles);

			if (ParseTaskFinished != null)
				ParseTaskFinished (pf);

			criticalPreparationSection.WaitOne ();
			var subTasks = im.parseSubTasksUntilFinished.ToArray ();

			if(p.im.basePath != null)
				ParseStatistics.Remove (p.im.basePath);

			criticalPreparationSection.Set ();

			foreach(var subtask in subTasks) {
				if (Interlocked.Decrement (ref subtask.i) < 1 && subtask.finishedHandler != null)
					subtask.finishedHandler (pf); // Generic issue: The wrong statistics will be passed, if we fire the event for a task which was added some time afterwards
			}

			if (Interlocked.Decrement (ref parsingThreads) <= 0)
				parseCompletedEvent.Set ();
		}