public void Start() { if (WorkerThread != null && WorkerThread.IsAlive) { // Cannot do that. return; } CeaseOperation = false; ThreadParamInfo threadParams = new ThreadParamInfo() { Address = BindAddress, Port = BindPort, Peers = MaximumPeers, Channels = MaximumChannels, PollTime = PollTime, PacketSizeLimit = MaximumPacketSize, Verbosity = Verbosity }; // Drain queues. if (Incoming != null) { while (Incoming.TryDequeue(out _)) { ; } } if (Outgoing != null) { while (Outgoing.TryDequeue(out _)) { ; } } if (Commands != null) { while (Commands.TryDequeue(out _)) { ; } } if (ConnectionEvents != null) { while (ConnectionEvents.TryDequeue(out _)) { ; } } if (DisconnectionEvents != null) { while (DisconnectionEvents.TryDequeue(out _)) { ; } } WorkerThread = new Thread(ThreadWorker); WorkerThread.Start(threadParams); }
public void Start() { if (WorkerThread != null && WorkerThread.IsAlive) { // Cannot do that. Debug.LogError("Ignorance Client: A worker thread is already running. Cannot start another."); return; } CeaseOperation = false; ThreadParamInfo threadParams = new ThreadParamInfo() { Address = ConnectAddress, Port = ConnectPort, Channels = ExpectedChannels, PollTime = PollTime, PacketSizeLimit = MaximumPacketSize, Verbosity = Verbosity }; // Drain queues. if (Incoming != null) { while (Incoming.TryDequeue(out _)) { ; } } if (Outgoing != null) { while (Outgoing.TryDequeue(out _)) { ; } } if (Commands != null) { while (Commands.TryDequeue(out _)) { ; } } if (ConnectionEvents != null) { while (ConnectionEvents.TryDequeue(out _)) { ; } } if (StatusUpdates != null) { while (StatusUpdates.TryDequeue(out _)) { ; } } WorkerThread = new Thread(ThreadWorker); WorkerThread.Start(threadParams); Debug.Log("Ignorance Client: Dispatched worker thread."); }
public void Start() { if (WorkerThread != null && WorkerThread.IsAlive) { // Cannot do that. Debug.LogError("Ignorance Server: A worker thread is already running. Cannot start another."); return; } CeaseOperation = false; ThreadParamInfo threadParams = new ThreadParamInfo() { Address = BindAddress, Port = BindPort, Peers = MaximumPeers, Channels = MaximumChannels, PollTime = PollTime, PacketSizeLimit = MaximumPacketSize, Verbosity = Verbosity }; // Drain queues. if (Incoming != null) { while (Incoming.TryDequeue(out _)) { ; } } if (Outgoing != null) { while (Outgoing.TryDequeue(out _)) { ; } } if (Commands != null) { while (Commands.TryDequeue(out _)) { ; } } if (ConnectionEvents != null) { while (ConnectionEvents.TryDequeue(out _)) { ; } } if (DisconnectionEvents != null) { while (DisconnectionEvents.TryDequeue(out _)) { ; } } WorkerThread = new Thread(ThreadWorker); WorkerThread.Start(threadParams); // Announce if (Verbosity > 0) { Debug.Log("Ignorance Server: Dispatched worker thread."); } }