Пример #1
0
        private static void CreateAccounts(IAccountServiceRpcClient client)
        {
            int             numThreads  = 10;
            int             numAccounts = 877;
            ParallelOptions opt         = new ParallelOptions()
            {
                MaxDegreeOfParallelism = numThreads
            };

            Parallel.For(0, numAccounts, opt, i => {
                var req = new AccountRequest {
                    FirstName = "Anthony " + i,
                    LastName  = "Chang"
                };
                Task <AccountResponse> resp = null;
                try {
                    resp = client.CreateAccountAsync(req).ResponseAsync;
                    resp.Wait();
                    Account account = resp.Result.Data;
                    Display(account.ToString());
                } catch (Exception e) {
                    Display("An error occurred: " + e.Message);
                }
            });
        }
Пример #2
0
        public override async Task <AccountResponse> CreateAccount(AccountRequest request, ServerCallContext context)
        {
            Logger.Here().Information("BGN");
            try {
                var response = accountService.CreateAccountAsync(request);

                Logger.Here().Information("END");
                return(await response);
            } catch (Exception e) {
                Logger.Here().Warning(e.Message);
                throw new RpcException(new Status(StatusCode.Internal, e.Message));
            }
        }