async void Process(IWorker worker) { try { _logger.Information(this, () => "Process"); var handler = _createHandler(); while (IsStarted && !worker.Closed) { // recieve any data, process it and send a response var request = await worker.ReceiveAsync(); if (request == null) { _logger.Information(this, () => "Process Connection Closed"); break; } var response = await handler.ProcessAsync(request); if (response == null) continue; await worker.SendAsync(response); break; } _logger.Information(this, () => "Process Complete"); } catch (Exception ex) { Stop(() => "Stopped on Process exception", ex); } worker.Close(); }