<commit_before>﻿//-----------------------------------------------------------------------
// <copyright file="Program.cs" company="<NAME>">
// Copyright (c) <NAME>. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace QueueSample
{
    using System;
    using System.Globalization;
    using System.Threading;
    using System.Threading.Tasks;

    internal sealed class Program
    {
        private static void Main(string[] args)
        {
            InputQueue<int> queue = new InputQueue<int>();
            using (CancellationTokenSource cts = new CancellationTokenSource())
            {
                Task enqueueTask = PrintException(EnqueueLoopAsync(queue, cts.Token));
                Task dequeueTask = PrintException(DequeueLoopAsync(queue, cts.Token));

                Console.WriteLine("Press ENTER to cancel.");
                Console.ReadLine();
                cts.Cancel();

                Task.WaitAll(enqueueTask, dequeueTask);
            }
        }

        private static async Task EnqueueLoopAsync(InputQueue<int> queue, CancellationToken token)
        {
            await Task.Yield();

            int i = 0;
            while (!token.IsCancellationRequested)
            {
                ++i;
                queue.Enqueue(i);
                await Task.Delay(1);
            }
        }

        private static async Task DequeueLoopAsync(InputQueue<int> queue, CancellationToken token)
        {
            await Task.Yield();

            int previous = 0;
            while (!token.IsCancellationRequested)
            {
                int current = await queue.DequeueAsync();
                if (current - previous != 1)
                {
                    string message = string.Format(CultureInfo.InvariantCulture, "Invalid data! Current is {0} but previous was {1}.", current, previous);
                    throw new InvalidOperationException(message);
                }

                previous = current;
            }
        }

        private static async Task PrintException(Task task)
        {
            try
            {
                await task;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
    }
}
<commit_msg>Add Dispose to integration app<commit_after>﻿//-----------------------------------------------------------------------
// <copyright file="Program.cs" company="<NAME>">
// Copyright (c) <NAME>. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace QueueSample
{
    using System;
    using System.Globalization;
    using System.Threading;
    using System.Threading.Tasks;

    internal sealed class Program
    {
        private static void Main(string[] args)
        {
            InputQueue<int> queue = new InputQueue<int>();
            using (CancellationTokenSource cts = new CancellationTokenSource())
            {
                Task enqueueTask = PrintException(EnqueueLoopAsync(queue, cts.Token));
                Task dequeueTask = PrintException(DequeueLoopAsync(queue, cts.Token));

                Console.WriteLine("Press ENTER to cancel.");
                Console.ReadLine();
                cts.Cancel();
                queue.Dispose();

                Task.WaitAll(enqueueTask, dequeueTask);
            }
        }

        private static async Task EnqueueLoopAsync(InputQueue<int> queue, CancellationToken token)
        {
            await Task.Yield();

            int i = 0;
            while (!token.IsCancellationRequested)
            {
                ++i;
                queue.Enqueue(i);
                await Task.Delay(1);
            }
        }

        private static async Task DequeueLoopAsync(InputQueue<int> queue, CancellationToken token)
        {
            await Task.Yield();

            int previous = 0;
            try
            {
                while (!token.IsCancellationRequested)
                {
                    int current = await queue.DequeueAsync();
                    if (current - previous != 1)
                    {
                        string message = string.Format(CultureInfo.InvariantCulture, "Invalid data! Current is {0} but previous was {1}.", current, previous);
                        throw new InvalidOperationException(message);
                    }

                    previous = current;
                }
            }
            catch (ObjectDisposedException)
            {
            }
        }

        private static async Task PrintException(Task task)
        {
            try
            {
                await task;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.1379174076269512, 'fraction_numerical': 0.0023710729104919974, 'mean_word_length': 1.1367665681722245, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008079', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1121, 'n_words': 268}