public void Enqueue(FileModelClass job) { lock (_jobs) { _jobs.Enqueue(job); if (!_delegateQueuedOrRunning) { _delegateQueuedOrRunning = true; ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null); } } }
static void Main(string[] args) { QueueWorker queueWorker = new QueueWorker(); Console.WriteLine("App started"); for (var i = 0; i < FilesToWrite; i++) { Console.WriteLine("Please, enter file name: "); var fileName = Console.ReadLine(); var fileEntityNewElement = new FileModelClass { FilePath = FilePath, FileName = fileName + ".txt" }; queueWorker.Enqueue(fileEntityNewElement); } }