Пример #1
0
        public int?CreateApplication(ApplicationExtendedModel application)
        {
            string json     = JsonSerializer.Serialize <ApplicationExtendedModel>(application);
            var    response = worker.SendMessage(createMessange + json);

            worker.Close();

            int id;

            return(!string.IsNullOrEmpty(response) && int.TryParse(response, out id) ? id : (int?)null);
        }
Пример #2
0
        public void Close(int requestId)
        {
            IWorker worker = GetWorker(requestId);

            if (worker != null)
            {
                worker.Close();
            }
        }
        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();
        }