private void BackThread() { while (!ShouldClose.Get()) { SpinWait.SpinUntil(() => CommandQueue.ExecuteFunction(x => x.Count) > 0 || Connection.Available > 0); if (Connection.Available > 0) { String Line = Reader.ReadLine(); Process(Line); } while (CommandQueue.ExecuteFunction(x => x.Count) > 0) { Byte[] data = System.Text.Encoding.UTF8.GetBytes(CommandQueue.ExecuteFunction(x => x.Dequeue())); NetStream.Write(data, 0, data.Length); } } Byte[] d2 = System.Text.Encoding.UTF8.GetBytes(String.Format("QUIT {0}\r\n", Configuration.QuitMessage)); NetStream.Write(d2, 0, d2.Length); }
/// <summary> /// Function to check if the channel has messages to be read /// </summary> /// <returns>If the channel has messages to be read</returns> public bool CanGetMessage() { return(MessageQueue.ExecuteFunction(x => x.Count > 0)); }