コード例 #1
0
        private bool _WCFサービスを取得する(out ChannelFactory <IDTXManiaService> factory, out IDTXManiaService service, out IClientChannel serviceChannel)
        {
            const int 最大リトライ回数 = 1;

            for (int retry = 1; retry <= 最大リトライ回数; retry++)
            {
                try
                {
                    var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                    factory        = new ChannelFactory <IDTXManiaService>(binding);
                    service        = factory.CreateChannel(new EndpointAddress(endPointUri));
                    serviceChannel = service as IClientChannel; // サービスとチャンネルは同じインスタンス。
                    serviceChannel.Open();

                    return(true);    // 取得成功。
                }
                catch
                {
                    // 取得失敗。少し待ってからリトライする。
                    if (最大リトライ回数 != retry)
                    {
                        System.Threading.Thread.Sleep(500);
                    }
                    continue;
                }
            }

            serviceChannel = null;
            service        = null;
            factory        = null;
            return(false);   // 取得失敗。
        }
コード例 #2
0
 private void _WCFサービスでオプションを処理する(IDTXManiaService service, CommandLineOptions options)
 {
     if (options.再生開始)
     {
         service.ViewerPlay(options.Filename, options.再生開始小節番号, options.ドラム音を発声する);
     }
     else if (options.再生停止)
     {
         service.ViewerStop();
     }
 }
コード例 #3
0
 private void _WCFサービスを解放する(ChannelFactory <IDTXManiaService> factory, IDTXManiaService service, IClientChannel serviceChannel)
 {
     serviceChannel?.Close();
     factory?.Close();
 }