private async Task SetEvent(string eventStr) { if (eventStr == EnumEvent.Idle) { await Task.Delay(50); } m_CurrentEvent = eventStr; EventStatus?.Invoke(this, null); }
public void Start(int port) { if (port < 0) { throw new ArgumentException($"{nameof(port)} is not be negative"); } else if (_thread != null) { return; } else { _thread = new Thread(() => { _socket.Bind(new IPEndPoint(IPAddress.Any, port)); _socket.Listen(_maxQueue); try { while (true) { EventStatus?.Invoke(ServerWaitStatus); var client = _socket.Accept(); client.Close(); } } catch (SocketException) { EventStatus?.Invoke(ServerClosedStatus); } }); _thread.Start(); } }