<commit_before>﻿using System;
using System.Diagnostics;
using System.Timers;

namespace InSimDotNet.Out {
    /// <summary>
    /// Abstract class for managing OutSim and OutGauge UDP connections with LFS.
    /// </summary>
    public abstract class OutClient : IDisposable {
        private readonly UdpSocket udpSocket;
        private readonly Timer timeoutTimer;
        private bool isDisposed;

        /// <summary>
        /// Occurs when the connection times out.
        /// </summary>
        public event EventHandler TimedOut;

        /// <summary>
        /// Occurs when an error occurs on the internal receive thread.
        /// </summary>
        public event EventHandler<OutErrorEventArgs> OutError;

        /// <summary>
        /// Gets if the socket is connected.
        /// </summary>
        public bool IsConnected {
            get { return timeoutTimer == null ? true : timeoutTimer.Enabled; }
        }

        /// <summary>
        /// Gets the amount of time to wait before timing out.
        /// </summary>
        public TimeSpan Timeout { get; private set; }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class.
        /// </summary>
        protected OutClient()
            : this(TimeSpan.Zero) { }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class with the specified timeout.
        /// </summary>
        /// <param name="timeout">The timeout period in milliseconds.</param>
        protected OutClient(int timeout)
            : this(TimeSpan.FromMilliseconds(timeout)) { }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class with the specified timeout.
        /// </summary>
        /// <param name="timeout">The timeout period for the socket.</param>
        protected OutClient(TimeSpan timeout) {
            udpSocket = new UdpSocket();
            udpSocket.PacketDataReceived += new EventHandler<PacketDataEventArgs>(udpSocket_PacketDataReceived);
            udpSocket.SocketError += new EventHandler<InSimErrorEventArgs>(udpSocket_SocketError);
<commit_msg>Added ContinueOnCapturedContext property to OutClient class.<commit_after>﻿using System;
using System.Diagnostics;
using System.Timers;

namespace InSimDotNet.Out {
    /// <summary>
    /// Abstract class for managing OutSim and OutGauge UDP connections with LFS.
    /// </summary>
    public abstract class OutClient : IDisposable {
        private readonly UdpSocket udpSocket;
        private readonly Timer timeoutTimer;
        private bool isDisposed;

        /// <summary>
        /// Occurs when the connection times out.
        /// </summary>
        public event EventHandler TimedOut;

        /// <summary>
        /// Occurs when an error occurs on the internal receive thread.
        /// </summary>
        public event EventHandler<OutErrorEventArgs> OutError;

        /// <summary>
        /// Gets if the socket is connected.
        /// </summary>
        public bool IsConnected {
            get { return timeoutTimer == null ? true : timeoutTimer.Enabled; }
        }

        /// <summary>
        /// Gets the amount of time to wait before timing out.
        /// </summary>
        public TimeSpan Timeout { get; private set; }

        /// <summary>
        /// Gets or sets whether packet handlers should be marshalled back onto the original context.
        /// </summary>
        public bool ContinueOnCapturedContext {
            get { return udpSocket.ContinueOnCapturedContext; }
            set { udpSocket.ContinueOnCapturedContext = value; }
        }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class.
        /// </summary>
        protected OutClient()
            : this(TimeSpan.Zero) { }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class with the specified timeout.
        /// </summary>
        /// <param name="timeout">The timeout period in milliseconds.</param>
        protected OutClient(int timeout)
            : this(TimeSpan.FromMilliseconds(timeout)) { }

        /// <summary>
        /// Creates a new instance of the <see cref="OutClient"/> class with the specified timeout.
        /// </summary>
        /// <param name="timeout">The timeout period for the socket.</param>
        protected OutClient(TimeSpan timeout) {
            udpSocket = new UdpSocket();
            udpSocket.PacketDataReceived += new EventHandler<PacketDataEventArgs>(udpSocket_PacketDataReceived);
            udpSocket.SocketError += new EventHandler<InSimErrorEventArgs>(udpSocket_SocketError);

{'fraction_non_alphanumeric': 0.10718870346598203, 'fraction_numerical': 0.0, 'mean_word_length': 2.0837730870712403, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, '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': '1333682', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1129, 'n_words': 376}