Exemplo n.º 1
0
        private async void Post(LoggingEvent[] logEvents)
        {
            _waitHandle.Reset();
            var payload = new
            {
                PID          = _pid,
                ProcessName  = _pName,
                Host         = _host,
                Sender       = Name,
                TimestampUTC = DateTimeOffset.UtcNow,
                BatchCount   = Interlocked.Increment(ref _counter),
                Entries      = GetEntries(logEvents)
            };

            using (var content = new JSONPushStreamContent(payload))
            {
                var response = await _client.PostAsync(Endpoint, content).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    return;
                }

                // Try once more
                await _client.PostAsync(Endpoint, content).ConfigureAwait(false);
            }
            _waitHandle.Set();
        }
Exemplo n.º 2
0
    private async Task <bool> DoPost(object payload)
    {
        using (var content = new JSONPushStreamContent(payload))
        {
            var response = await _client.PostAsync(Endpoint, content).ConfigureAwait(false);

            return(response.IsSuccessStatusCode);
        }
    }