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


C# TcpChannel.StopListening方法代码示例

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


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

示例1: Main

        private static void Main(string[] args)
        {
            var channelServ = new TcpChannel();
            ChannelServices.RegisterChannel(channelServ, false);

            var mainServer = (IMainServer) Activator.GetObject(typeof (IMainServer), Config.RemoteMainserverUrl);
            ServerInit serverInit = mainServer.AddServer();

            channelServ.StopListening(null);
            ChannelServices.UnregisterChannel(channelServ);

            var server = new Server(serverInit);
            IDictionary properties = new Hashtable();
            int serverPort = Config.GetServerPort(serverInit.Uuid);
            const int serverTimeout = Config.InvocationTimeout;
            properties["port"] = serverPort;
            properties["timeout"] = serverTimeout;
            channelServ = new TcpChannel(properties, null, null);
            ChannelServices.RegisterChannel(channelServ, false);
            RemotingServices.Marshal(server, Config.RemoteServerObjName);

            server.StartSplitLock();

            foreach (var faultDetection in serverInit.FaultDetection)
            {
                var fd = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(faultDetection.Key));
                fd.OnFaultDetectionReborn(serverInit.Uuid);
            }

            int backupId = -1;
            if ((serverInit.FaultDetection.Count == 1 && serverInit.FaultDetection.ContainsKey(serverInit.Parent) &&
                 serverInit.Parent != -1) || (serverInit.FaultDetection.Count == 0 && serverInit.Parent != -1))
            {
                backupId = serverInit.Parent;
            }
            else if (serverInit.FaultDetection.Count > 0)
            {
                backupId = serverInit.FaultDetection.Keys.Max();
            }

            if (backupId != -1)
            {
                /* Get data from backup */
                var backupServer = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(backupId));
                backupServer.StartSplitLock();
                ParticipantStatus status = backupServer.OnChild(serverInit.Uuid, serverInit.Version,
                    serverInit.ServerCount);
                server.SetStatus(status);
                backupServer.EndSplitLock();
            }
            else
            {
                Console.WriteLine("Server need to have a backup server! Is it the first one?");
            }

            server.EndSplitLock();

            Console.WriteLine("Press <enter> to exit");
            Console.ReadLine();
        }
开发者ID:rtfpessoa,项目名称:padi-dstm,代码行数:60,代码来源:Program.cs

示例2: Run

        public void Run()
        {
            IDictionary properties = new Hashtable();
            properties["port"] = 9997;
            properties["timeout"] = 5000;
            properties["retryCount"] = 2;
            var channelServ = new TcpChannel(properties, null, null);
            ChannelServices.RegisterChannel(channelServ, true);

            Console.WriteLine("Waiting for init. Press to start:");
            Console.ReadLine();

            var mainServer = (IMainServer) Activator.GetObject(typeof (IMainServer), Config.RemoteMainserverUrl);
            var server = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(0));

            int txid = mainServer.StartTransaction();
            server.WriteValue(0, txid, 1, 1);
            server.Freeze();
            server.WriteValue(0, txid, 1, 2);
            Console.WriteLine("Waiting for recover. Press to start:");
            Console.ReadLine();
            server.Recover();
            mainServer.CommitTransaction(txid);

            channelServ.StopListening(null);
            ChannelServices.UnregisterChannel(channelServ);
        }
开发者ID:rtfpessoa,项目名称:padi-dstm,代码行数:27,代码来源:TransactionsTests.cs

示例3: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            //Button Connect has been pressed
            MinMax.Server_Client_Dialogue ConnectForm = new MinMax.Server_Client_Dialogue();
            // Create a new Connect Form.
            ConnectForm.Show();

            ConnectForm.label1.Text = "1 - Connecting to the Server at the IP :"+this.textBox2.Text;
            ConnectForm.label1.Text = ConnectForm.label1.Text + "\n2 - Opening TCP Channel.";
            TcpChannel chan = new TcpChannel();
            try {
                // Attempt to get a connection and a
                // channel opening to the TaskServer

                ChannelServices.RegisterChannel(chan,false);
                ConnectForm.label1.Text += "\n3 - Registering TCP Channel.";

                TaskServer.TaskRunner taskRunner = (TaskServer.TaskRunner)Activator.GetObject(typeof(TaskServer.TaskRunner),
                                                              "tcp://" + this.textBox2.Text + ":8085/TaskServer");
                //The Server is Not Running if taskRunner is null.
                if (taskRunner == null)
                {
                    ConnectForm.label1.Text += "\nError -  Could not locate server.";
                    chan.StopListening(true);
                    return;
                }

                ConnectForm.label1.Text += "\nClick Calculate to begin the Calculation.";

            } catch (Exception t) {

                ConnectForm.label1.Text = ConnectForm.label1.Text +"\n[e] An exception occurred." ;
                ConnectForm.label1.Text= ConnectForm.label1.Text + t;
                chan.StopListening(true);
            }
        }
开发者ID:ddimitriou,项目名称:Min-Max,代码行数:36,代码来源:Client.cs


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