using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Skyscraper.FrequencyListGenerator
{
	public class TaskQueue
	{
		public TaskQueue()
		{
			tasks = new Queue<Action>();
		}

		private Queue<Action> tasks;

		public void EnqueueTask(Action a)
		{
			lock (this)
			{
				tasks.Enqueue(a);
			}
		}

		public void ProcessTasks()
		{
			lock (this)
			{
				while (tasks.Count > 0)
				{
					Action dequeue = tasks.Dequeue();
					dequeue.Invoke();
				}
			}
		}
	}
}
