当前位置: 首页>>代码示例>>C#>>正文


C# ChannelFactory.Abort方法代码示例

本文整理汇总了C#中System.ServiceModel.ChannelFactory.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# ChannelFactory.Abort方法的具体用法?C# ChannelFactory.Abort怎么用?C# ChannelFactory.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.ChannelFactory的用法示例。


在下文中一共展示了ChannelFactory.Abort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Abort

 private static void Abort(IChannel channel, ChannelFactory channelFactory)
 {
     if (channel != null)
         channel.Abort();
     if (channelFactory != null)
         channelFactory.Abort();
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:client.cs

示例2: Abort

 static void Abort(IChannel channel, ChannelFactory cf)
 {
     if (channel != null)
         channel.Abort();
     if (cf != null)
         cf.Abort();
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:client.cs

示例3: VerifyServiceIdentityMatchDnsEndpointIdentity

        // The product code will check the Dns identity from the server and throw if it does not match what is specified in DnsEndpointIdentity
        public static void VerifyServiceIdentityMatchDnsEndpointIdentity()
        {
            string testString = "Hello";

            NetTcpBinding binding = new NetTcpBinding();
            //SecurityMode.Transport is not supported yet, we will get an exception here, tracked by issue #81
            binding.Security.Mode = SecurityMode.Transport;
            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

            EndpointAddress endpointAddress = new EndpointAddress(new Uri(Endpoints.Tcp_VerifyDNS_Address),new DnsEndpointIdentity("localhost"));
            ChannelFactory<IWcfService> factory = new ChannelFactory<IWcfService>(binding, endpointAddress);
            // factory.Credentials.ServiceCertificate is not availabe currently, tracked by issue 243
            // We need to change the validation mode as we use a test certificate. It does not affect the purpose of this test
            // factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            IWcfService serviceProxy = factory.CreateChannel();

            try
            {
                var result = serviceProxy.Echo(testString);
                Assert.Equal(testString, result);
            }
            finally
            {
                if (factory != null && factory.State != CommunicationState.Closed)
                {factory.Abort();
                }
            }
        }
开发者ID:dmetzgar,项目名称:wcf,代码行数:29,代码来源:IdentityTests.cs

示例4: bPipe_Click

        private void bPipe_Click(object sender, EventArgs e)
        {
            //ChannelFactory<IDesktopService> httpFactory = new ChannelFactory<IDesktopService>(new WebHttpBinding(),
            //    new EndpointAddress("http://localhost:8000/Desk"));

            //IDesktopService httpProxy =
            //  httpFactory.CreateChannel();
            ChannelFactory<IDesktopService> pipeFactory = null;
            try
            {
                var b = new NetNamedPipeBinding();
                b.MaxReceivedMessageSize = int.MaxValue;
                b.MaxBufferSize = int.MaxValue;
                pipeFactory =
                    new ChannelFactory<IDesktopService>(b,
                        new EndpointAddress("net.pipe://localhost/DeskPipe"));

                IDesktopService pipeProxy =
                    pipeFactory.CreateChannel();
                sw.Start();
                var d = pipeProxy.C("par");
                sw.Stop();
                box.Text += "GetData returned {0} bytes and costed {1} ms\r\n".Fmt(d.Result.ToString().Length, sw.ElapsedMilliseconds);
                var s = d.Result.ToString();
                if (!string.IsNullOrEmpty(s))
                {
                    var bytes = Convert.FromBase64String(s);
                    using (var ms = new MemoryStream())
                    {
                        ms.Write(bytes, 0, bytes.Length);
                        var bmp = Image.FromStream(ms);
                        pic.Image = bmp;
                    }
                }
                //var img = d.Result as Bitmap;
                //pic.Image = img;
            }
            catch (Exception ex)
            {
                Error.Handle(ex);
            }
            finally
            {
                sw.Reset();
                if (pipeFactory != null && pipeFactory.State != CommunicationState.Closed)
                {
                    if (pipeFactory.State == CommunicationState.Faulted)
                    {
                        pipeFactory.Abort();
                    }
                    else
                    {
                        pipeFactory.Close();
                    }
                }
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:57,代码来源:WcfForm.cs

示例5: CallSyncService

        private string CallSyncService()
        {
            string lResult = string.Empty;

            if (mut.WaitOne(0))
            {
                try
                {
                    var lServiceHostAddress = new Uri(Properties.Settings.Default.ServiceHostAddress);
                    var lServiceEndPointAddress = Properties.Settings.Default.ServiceEndPointAddress;
                    var lEndPointAddress =
                        new EndpointAddress(new Uri(String.Format("{0}/{1}", lServiceHostAddress, lServiceEndPointAddress)));
                    this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: lEndPointAddress = {0}", lEndPointAddress);

                    var lBinding = new TcpChunkingBinding();
                    lBinding.OpenTimeout = Properties.Settings.Default.OpenTimeout;
                    lBinding.ReceiveTimeout = Properties.Settings.Default.ReceiveTimeout;
                    lBinding.SendTimeout = Properties.Settings.Default.SendTimeout;
                    lBinding.CloseTimeout = Properties.Settings.Default.CloseTimeout;

                    this.WriteLog(USLogLevel.Trace, "lBinding params lBinding.OpenTimeout = {0}; lBinding.ReceiveTimeout = {1}; lBinding.SendTimeout = {2}; lBinding.CloseTimeout = {3}", lBinding.OpenTimeout, lBinding.ReceiveTimeout, lBinding.SendTimeout, lBinding.CloseTimeout);

                    using (var factory = new ChannelFactory<IUSInService>(lBinding, lEndPointAddress))
                    {
                        try
                        {
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: ChannelFactory created");
                            var service = factory.CreateChannel();
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: IUSExService service = factory.CreateChannel created");
                            lResult = service.EntitySync(LinkSyncServiceEntitiesId);
                            this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: service.EntitySync выполнен");
                            factory.Close();
                        }
                        finally
                        {
                            factory.Abort();
                        }
                    }
                    this.WriteLog(USLogLevel.Trace, "SyncServiceProperties.CallSyncService: ChannelFactory Closed");
                }
                catch (Exception e)
                {
                    this.WriteLog(USLogLevel.Trace|USLogLevel.Debug, string.Format("SyncServiceProperties.CallSyncService: Ошибка синхронизации LinkSyncServiceEntitiesId = {0}. Ошибка: {1}", LinkSyncServiceEntitiesId, e));
                    this.WriteLogException(string.Format("SyncServiceProperties.CallSyncService: Ошибка синхронизации LinkSyncServiceEntitiesId = {0}. Ошибка: {1}", LinkSyncServiceEntitiesId, e), e);
                    lResult = string.Empty;
                }
                finally
                {
                    mut.ReleaseMutex();                    
                }
            }

            return lResult;
        }
开发者ID:distributor,项目名称:distributor.sync.service,代码行数:54,代码来源:SyncServiceProperties.cs

示例6: CreateDashboardPipe

 private void CreateDashboardPipe()
 {
     try{
         //Connect to the master channel
         m_DasboardComFactory = new ChannelFactory<ICTMComR2D>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/Dashboard/CTMComR2D"));
         m_DashboardPipe = m_DasboardComFactory.CreateChannel();
     }
     catch
     {
         m_DasboardComFactory.Abort();
     }
 }
开发者ID:redrhino,项目名称:cAlgo.Trade.Manager,代码行数:12,代码来源:RobotBridge.cs

示例7: Authenticate

        public AuthenticationResponse Authenticate(AuthenticationRequest request)
        {
            ChannelFactory<IAuthenticationService> channelFactory = null;
            AuthenticationResponse response = null;
            try
            {
                channelFactory = new ChannelFactory<IAuthenticationService>("authentication");
                channelFactory.Open();

                var service = channelFactory.CreateChannel();

                response = service.Authenticate(request);

                channelFactory.Close();
            }
            catch (CommunicationException)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
            }
            catch (TimeoutException)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
            }
            catch (Exception)
            {
                if (channelFactory != null)
                {
                    channelFactory.Abort();
                }
                throw;
            }

            return response;
        }
开发者ID:AgileSight,项目名称:ActiveDirectoryForCloud,代码行数:40,代码来源:AuthenticationClient.cs

示例8: bError_Click

	    private void bError_Click(object sender, EventArgs e)
		{
			using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.NetTcpAddress))
			{
				try
				{
					ITestService ts = cf.CreateChannel();
					ts.TestError();
				}
				catch(FaultException ex)
				{
					MessageBox.Show(ex.ToString());
					cf.Abort();
				}
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:16,代码来源:Client.cs

示例9: Dispose

 public void Dispose()
 {
     try
     {
         _remoteFactory.Close();
         _remoteFactory = null;
     }
     catch
     {
         if (_remoteFactory != null)
         {
             _remoteFactory.Abort();
             _remoteFactory = null;
         }
     }
 }
开发者ID:reaperdk,项目名称:timetracker,代码行数:16,代码来源:WcfConnectionService.cs

示例10: GETTest

        public void GETTest()
        {
            GeoLocation output = null;
            var factory = new ChannelFactory<IService<GeoLocation>>("GeoLocationService");
            if (factory.State != CommunicationState.Faulted)
            {
                var proxy = factory.CreateChannel();
                output = proxy.Read("werwtw4hej3u");
                Console.WriteLine(output.Identifier);
                if (factory.State == CommunicationState.Faulted)
               {
                    factory.Abort();
                }
                ((IDisposable)proxy).Dispose();
            }

            Assert.IsNotNull(output);
        }
开发者ID:frymirep,项目名称:FireCreek,代码行数:18,代码来源:UnitTest1.cs

示例11: Address

        /// <summary>
        /// 此静态构造函数用来检测存活的Search个数
        /// </summary>
        static Address()
        {
            Timer timer = new Timer();
            timer.Interval = 6000;
            timer.Elapsed += (sender, e) =>
            {

                Console.WriteLine("\n***************************************************************************");
                Console.WriteLine("当前存活的Search为:");

                lock (obj)
                {
                    //遍历当前存活的Search
                    foreach (var single in search)
                    {
                        ChannelFactory<IProduct> factory = null;

                        try
                        {
                            //当Search存在的话,心跳服务就要定时检测Search是否死掉,也就是定时的连接Search来检测。
                            factory = new ChannelFactory<IProduct>(new NetTcpBinding(SecurityMode.None), new EndpointAddress(single));
                            factory.CreateChannel().TestSearch();
                            factory.Close();

                            Console.WriteLine(single);

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);

                            //如果抛出异常,则说明此search已经挂掉
                            search.Remove(single);
                            factory.Abort();
                            Console.WriteLine("\n当前时间:" + DateTime.Now + " ,存活的Search有:" + search.Count() + "个");
                        }
                    }
                }

                //最后统计下存活的search有多少个
                Console.WriteLine("\n当前时间:" + DateTime.Now + " ,存活的Search有:" + search.Count() + "个");
            };
            timer.Start();
        }
开发者ID:refinedKing,项目名称:HeartBeat,代码行数:47,代码来源:Address.cs

示例12: bTest_Click

        private void bTest_Click(object sender, EventArgs e)
	    {
	        var binding = new NetTcpBinding(SecurityMode.Transport);
	        using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(binding, TestService.NetTcpAddress))
	        {
                ITestService ts = cf.CreateChannel();
                for (int i = 0; i < 10; i++)
	            {
	                try
	                {
                        var rlt = ts.Test();
                        Log(rlt);
	                }
	                catch (Exception ex)
	                {
	                    Log(ex.Message);
	                    cf.Abort();
	                }
	            }
	        }
	    }
开发者ID:mind0n,项目名称:hive,代码行数:21,代码来源:Client.cs

示例13: Main

        static void Main(string[] args)
        {
            using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.NetTcpAddress))
            {
                ITestService ts = cf.CreateChannel();
                for (int i = 0; i < 10; i++)
                {
                    try
                    {
                        var rlt = ts.Test();
                        Log(rlt);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.Message);
                        cf.Abort();
                    }
                }
            } 

            //using (ChannelFactory<ITestService> cf = new ChannelFactory<ITestService>(new NetTcpBinding(), TestService.Address))
            //{
            //    ITestService ts = cf.CreateChannel();
            //    for (int i = 0; i < 10; i++)
            //    {
            //        try
            //        {
            //            var rlt = ts.Test();
            //            Log(rlt);
            //        }
            //        catch (Exception ex)
            //        {
            //            Log(ex.Message);
            //            cf.Abort();
            //        }
            //    }
            //}
            Console.ReadKey();
        }
开发者ID:mind0n,项目名称:hive,代码行数:39,代码来源:Program.cs

示例14: POSTTest

        public void POSTTest()
        {
            var input = new GeoLocation
                               {
                                   Accuracy = 1.26743233E+14,
                                   Altitude = 1.26743233E+14,
                                   AltitudeAccuracy = 1.26743233E+14,
                                   Heading = 1.26743233E+14,
                                   Latitude = 1.26743233E+14,
                                   Longitude = 1.26743233E+14,
                                   Speed = 1.26743233E+14,
                                   Timestamp = DateTime.Parse("1999-05-31T11:20:00")
                               };
            GeoLocation output = null;
            var factory = new ChannelFactory<IService<GeoLocation>>("GeoLocationService");
            if (factory.State != CommunicationState.Faulted)
            {
                var proxy = factory.CreateChannel();
                try
                {
                    output = proxy.Create(input);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.InnerException.StackTrace);
                }
                Console.WriteLine(output.Identifier);
                if (factory.State == CommunicationState.Faulted)
                {
                    factory.Abort();
                }
                ((IDisposable)proxy).Dispose();
            }

            Assert.IsNotNull(output);
        }
开发者ID:frymirep,项目名称:FireCreek,代码行数:37,代码来源:UnitTest1.cs

示例15: worker

        internal static void worker(int loop, string name)
        {
            //ThreadPool.QueueUserWorkItem(delegate
            //{
                ChannelFactory<ITest> factory = null;
                try
                {
                    factory = new ChannelFactory<ITest>(name);
                    var channel = factory.CreateChannel();

                    using (var ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        var response = string.Empty;
                        response = channel.Ping2(loop);
                        //channel.Ping(loop);
                       
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(string.Format("[{0}, {1}]: {2}, tid={3}\n", loop, name, response, Thread.CurrentThread.GetHashCode()));
                        Console.ResetColor();

                        //Thread.Sleep(1000);

                        Console.WriteLine("\n+++ Press 'a' to abort or any key to finish a transaction. Timeout = 60sec. +++\n");

                        var ki = Console.ReadKey();
                        if (ki.Key == ConsoleKey.A)
                        {
                            throw new Exception("M A N U A L Y  A B O R T E D");
                        }
                                 
                        ts.Complete();
                    }
                    ((IChannel)channel).Close();
                    factory.Close();
                }
                catch (Exception ex)
                {
                    if (factory != null) factory.Abort();

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n" + ex.Message);
                    Console.ResetColor();
                }

            //});
        }
开发者ID:MatthewChudleigh,项目名称:solipsist,代码行数:46,代码来源:Program.cs


注:本文中的System.ServiceModel.ChannelFactory.Abort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。