private async ValueTask EventAsyncWorker() { while (!token.IsCancellationRequested && await channelAsyncData.Reader.WaitToReadAsync(token)) { if (channelAsyncData.Reader.TryRead(out EventItem item)) { DataReadyAsyncEvent?.Invoke(item.IP, item.Port, item.Time, item.Data, item.ID, item.IpUInt); } } }
private void OnCommunicatorAsyncData(string ip, int port, long time, IMemoryOwner <byte> data, string ID, uint ipuint) { // Launched by threadpool in dedicated thread (different from socket). Dispose IMemoryOwner so it goes back to Pool DataReadyAsyncEvent?.Invoke(ip, port, time, data, ID, ipuint); }