Creates a synchronization helper that will assist object synchronizing in a tight inner loop.
For streaming protocols, it is cost prohibited to tightly coordinate the inner loop. This class will help coordinate these efforts by signaling when a good time to perform synchronized work would be. For Example, when writing to a socket, calling BeginSafeToCallbackRegion would be good to do when the socket makes any kind of blocking call, such as flusing to an underlying socket. Upon returning from this command, calling EndSafeToCallbackRegion will return this class to a state where callback will not be executed. It is critical that BeginSafeToCallbackRegion, EndSafeToCallbackRegion, and PulseSafeToCallback only be called by the worker thread, as these methods are not thread safe and control the state of the WorkerThreadSynchronization. In easy terms. When you (the worker) get a convenient time, I need to do something that might modify your current working state. Let me know when I can do that.
Inheritance: GSF.Diagnostics.DisposableLoggingClassBase
        public NetworkBinaryStream(Socket socket, int timeout = -1, WorkerThreadSynchronization workerThreadSynchronization = null)
            : base(new NetworkStream(socket), workerThreadSynchronization)
        {
            if (!BitConverter.IsLittleEndian)
                throw new Exception("BigEndian processors are not supported");

            m_socket = socket;
            Timeout = timeout;
            m_socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
        }
        /// <summary>
        /// Creates a <see cref="RemoteBinaryStream"/>
        /// </summary>
        /// <param name="stream">the underlying stream to wrap</param>
        /// <param name="workerThreadSynchronization">the synchronization object</param>
        public RemoteBinaryStream(Stream stream, WorkerThreadSynchronization workerThreadSynchronization = null)
        {
            if (!BitConverter.IsLittleEndian)
                throw new Exception("BigEndian processors are not supported");

            if (workerThreadSynchronization == null)
                workerThreadSynchronization = new WorkerThreadSynchronization();

            m_workerThreadSynchronization = workerThreadSynchronization;
            m_receiveBuffer = new byte[BufferSize];
            m_sendBuffer = new byte[BufferSize];
            m_sendLength = 0;
            m_receiveLength = 0;
            m_receivePosition = 0;
            m_stream = stream;
        }