protected virtual void OnCommandSending(SerialEventArgs info) { if (CommandSending != null) { Task.Run(() => CommandSending?.Invoke(this, info)); } }
private async Task InitServiceHub() { _serviceHub = new SerialServiceHub(WebServerUrl, this); var connection = await _serviceHub.Start(); connection.On("queueEmpty", (int id) => { if (PortId == id) { CommandQueueEmpty?.Invoke(this, new SerialEventArgs()); } }); connection.On("queueChanged", (int id, int queuelength) => { if (PortId == id) { CommandQueueChanged?.Invoke(this, new SerialEventArgs(queuelength, null)); } }); connection.On("sendingCommand", (int id, int seqId) => { if (PortId == id) { CommandSending?.Invoke(this, new SerialEventArgs(new SerialCommand() { SeqId = seqId })); } }); }