Exemple #1
0
        private static async Task TestBolt(ILogger <Program> logger, CancellationToken cancellationToken)
        {
            // create Bolt proxy
            ClientConfiguration configuration = new ClientConfiguration();
            IDummyContract      proxy         = configuration.CreateSessionProxy <IDummyContract>("http://localhost:5000");
            await proxy.AuthenticateAsync("Dummy User");

            for (int i = 0; i < 10; i++)
            {
                // we can add timeout and CancellationToken to each Bolt call
                using (new RequestScope(TimeSpan.FromSeconds(5), cancellationToken))
                {
                    try
                    {
                        await proxy.ExecuteAsync(i.ToString(CultureInfo.InvariantCulture));
                    }
                    catch (OperationCanceledException)
                    {
                        // ok
                    }
                    catch (Exception e)
                    {
                        logger.LogInformation("Client: Error {0}", e.Message);
                    }
                }

                try
                {
                    await Task.Delay(10, cancellationToken);
                }
                catch (OperationCanceledException)
                {
                    return;
                }
            }
        }
 protected virtual IDummyContract CreateChannel()
 {
     return(ClientConfiguration.CreateSessionProxy <IDummyContract>(ServerUrl));
 }