Microsoft.HockeyApp.Channel.Transmission.SendAsync C# (CSharp) Méthode

SendAsync() public méthode

Executes the request that the current transmission represents.
public SendAsync ( ) : Task
Résultat Task
        public virtual async Task SendAsync()
        {
            if (Interlocked.CompareExchange(ref this.isSending, 1, 0) != 0)
            {
                throw new InvalidOperationException("SendAsync is already in progress.");
            }

            try
            {
                var httpService = ServiceLocator.GetService<IHttpService>();
                await httpService.PostAsync(this.EndpointAddress, Content, ContentType, ContentEncoding, this.Timeout);
            }
            finally
            {
                Interlocked.Exchange(ref this.isSending, 0);
            }
        }
    }

Usage Example

        /// <summary>
        /// Serializes a list of telemetry items and sends them.
        /// </summary>
        private async Task Send(IEnumerable <ITelemetry> telemetryItems)
        {
            if (telemetryItems == null || !telemetryItems.Any())
            {
                CoreEventSource.Log.LogVerbose("No Telemetry Items passed to Enqueue");
                return;
            }

            byte[] data         = JsonSerializer.Serialize(telemetryItems);
            var    transmission = new Transmission(this.endpointAddress, data, "application/x-json-stream", JsonSerializer.CompressionType);

            await transmission.SendAsync().ConfigureAwait(false);
        }
All Usage Examples Of Microsoft.HockeyApp.Channel.Transmission::SendAsync