Пример #1
0
 public void Enqueue(FileModelClass job)
 {
     lock (_jobs)
     {
         _jobs.Enqueue(job);
         if (!_delegateQueuedOrRunning)
         {
             _delegateQueuedOrRunning = true;
             ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null);
         }
     }
 }
Пример #2
0
        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);
            }
        }