private void OnRecive(IAsyncResult result) { try { if (Socket != null) { var endpoint = new IPEndPoint(IPAddress.Any, 0); var receiveBytes = Socket?.EndReceive(result, ref endpoint); if (receiveBytes != null && receiveBytes.Length > 0) { ReciveHandler?.Invoke(receiveBytes, receiveBytes.Length, endpoint); } StartRecive(); } } catch (ObjectDisposedException e) { //ok } catch (Exception e) { Logger.Error(e); } }
public I2CManager(ReciveHandler reciveHandler, ref I2cDevice device) { this.device = device; OnReciveHander = reciveHandler; }