public void Start() { if (thread != null && thread.IsAlive) { throw new InvalidOperationException("Packet buffer already started."); } if (!stream.IsConnected()) { throw new InvalidOperationException("Packet stream is not connected."); } if (stream.PacketHandler == null) { throw new InvalidOperationException("Packet stream's handler has not been set."); } //Create a new thread instance to handle the "run" method. thread = new Thread(new ThreadStart(run)); //Background threads will not make the CLR pend for them to close on exit (Java's "daemon" threads) thread.IsBackground = true; //Ensure the priority is set to lowest, since these are background operations. thread.Priority = ThreadPriority.Lowest; //Start the thread. thread.Start(); }
/// <summary> /// Gets the network online status of this contact. /// </summary> /// <returns> /// True if the sender is currently online, and available to recieve messages, /// regardless of the contact's online status (i.e. invisible) /// </returns> public bool IsConnected() { return(packetStream != null && packetStream.IsConnected()); }