コード例 #1
0
ファイル: Program.cs プロジェクト: knightfall/writeasync
        private static async Task RunServiceAsync(Uri address, CancellationToken token)
        {
            CalculatorServiceHost host = new CalculatorServiceHost(TimeSpan.FromMilliseconds(100.0d), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), address);
            await host.OpenAsync();

            while (!token.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(TimeSpan.FromSeconds(5.0d), token);
                    await host.RecycleAsync();
                }
                catch (OperationCanceledException)
                {
                }
            }

            await host.CloseAsync();
        }
コード例 #2
0
        private static async Task RunServiceAsync(Uri address, CancellationToken token)
        {
            CalculatorServiceHost host = new CalculatorServiceHost(TimeSpan.FromMilliseconds(100.0d), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), address);
            await host.OpenAsync();

            while (!token.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(TimeSpan.FromSeconds(5.0d), token);

                    await host.RecycleAsync();
                }
                catch (OperationCanceledException)
                {
                }
            }

            await host.CloseAsync();
        }