Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.Example.TcpRegisterClient", out createdProcessWait);

            if (createdProcessWait)
            {
                using (processWait)
                {
                    Console.WriteLine(@"http://www.AutoCSer.com/TcpServer/Register.html
");
                    try
                    {
                        AutoCSer.Threading.ThreadPool.TinyBackground.Start(clientThread);
                        AutoCSer.Net.TcpInternalServer.Server server = null;
                        RegisterClientTestServer test = new RegisterClientTestServer();
                        do
                        {
                            AutoCSer.Net.TcpInternalServer.Server newServer = AutoCSer.Net.TcpInternalServer.Emit.Server <IRegisterClientTestServer> .Create(test, AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute));

                            if (newServer.IsListen)
                            {
                                if (server != null)
                                {
                                    server.Dispose();
                                }
                                server = newServer;
                                Console.WriteLine(@"
Version:" + test.Version.toString());
                            }
                            else
                            {
                                Console.WriteLine(@"
测试服务启动失败");
                            }
                            Thread.Sleep(5000);
                            if (test.Version == 9)
                            {
                                Console.WriteLine(@"
测试结束");
                                isEnd = true;
                                if (server != null)
                                {
                                    server.Dispose();
                                }
                                Console.ReadKey();
                                return;
                            }
                            ++test.Version;
                        }while (true);
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    Console.ReadKey();
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
#if DotNetStandard
            Console.WriteLine("WARN : Linux .NET Core not support name EventWaitHandle");
#else
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.Example.TcpRegisterClient", out createdProcessWait);
            if (createdProcessWait)
            {
                using (processWait)
                {
#endif
            Console.WriteLine(@"http://www.AutoCSer.com/TcpServer/Register.html
");
            try
            {
                AutoCSer.Threading.ThreadPool.TinyBackground.Start(clientThread);
                AutoCSer.Net.TcpInternalServer.Server server = null;
                RegisterClientTestServer test = new RegisterClientTestServer();
                do
                {
                    AutoCSer.Net.TcpInternalServer.ServerAttribute attribute = AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute);

                    attribute.Port = 30000 + test.Version;
                    AutoCSer.Example.TcpRegisterClient.RegisterClientTestServer.TcpInternalServer newServer = new RegisterClientTestServer.TcpInternalServer(attribute, null, test);
                    if (newServer.IsListen)
                    {
                        if (server != null)
                        {
                            server.Dispose();
                        }
                        server = newServer;
                        Console.WriteLine(@"
Version:" + test.Version.toString());
                    }
                    else
                    {
                        Console.WriteLine(@"
测试服务启动失败");
                    }
                    Thread.Sleep(5000);
                    if (test.Version == 9)
                    {
                        Console.WriteLine(@"
测试结束");
                        isEnd = true;
                        if (server != null)
                        {
                            server.Dispose();
                        }
                        Console.ReadKey();
                        return;
                    }
                    test = new RegisterClientTestServer {
                        Version = test.Version + 1
                    };
                }while (true);
            }
            catch (Exception error)
            {
                Console.WriteLine(error.ToString());
            }
            Console.ReadKey();
#if !DotNetStandard
        }
    }
#endif
        }