Example #1
0
        static void Main(string[] args) {
            Console.WriteLine("Started");
            var items = CreateItem(ItemsLength).ToList();
            for (int i = 0; i < EnqueueThreads; i++) {
                Task.Run(async () => {
                    var en = new Enqueuer();
                    await en.Enqueue(items);
                });
            }
            for (int i = 0; i < DequeueThreads; i++) {
                Task.Run(async () => {
                    var de = new Dequeuer();
                    await de.Dequeue();
                });
            }
            Task.Run(async () => {
                using (var q = new DirectoryQueue("queue")) {
                    while (Program.Running) {
                        await Task.Delay(2000);
                        var info = q.GetQueueInfo();
                        Console.WriteLine($"-> Queue -> Enqueued: {info.Enqueued} Error: {info.Error} Total: {Program.Dequeued}");
                    }
                }
            });
            StartQueueCleaner();


            Console.WriteLine("Running");
            Console.ReadLine();
            Console.WriteLine("Stopping");
            Running = false;
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Started");
            var items = CreateItem(ItemsLength).ToList();

            for (int i = 0; i < EnqueueThreads; i++)
            {
                Task.Run(async() => {
                    var en = new Enqueuer();
                    await en.Enqueue(items);
                });
            }
            for (int i = 0; i < DequeueThreads; i++)
            {
                Task.Run(async() => {
                    var de = new Dequeuer();
                    await de.Dequeue();
                });
            }
            Task.Run(async() => {
                using (var q = new DirectoryQueue("queue")) {
                    while (Program.Running)
                    {
                        await Task.Delay(2000);
                        var info = q.GetQueueInfo();
                        Console.WriteLine($"-> Queue -> Enqueued: {info.Enqueued} Error: {info.Error} Total: {Program.Dequeued}");
                    }
                }
            });
            StartQueueCleaner();


            Console.WriteLine("Running");
            Console.ReadLine();
            Console.WriteLine("Stopping");
            Running = false;
            Console.ReadLine();
        }