static void test2()
        {
            Console.Write("PORT:");
            int port = int.Parse(Console.ReadLine());

            Client.Client client = new Client.Client("127.0.0.1", 9840, port);
            client.Init();
            ClientUser    c  = client.UserInfo;
            NCAsyncResult aa = (NCAsyncResult)client.BeginLogin("1501", "123", ar =>
                                                                { }
                                                                , null);

            while (!aa.IsCompleted)
            {
                Console.WriteLine("等待中。。。");
            }
            Console.WriteLine(aa.BaseResult.ToString() + aa.Info);

            client.BeginLogin("0000", "123456", ar =>
            {
                var a = (NCAsyncResult)ar;
                Console.WriteLine(a.BaseResult.ToString() + a.Info);
            }
                              , null);
            Console.Read();
        }
Esempio n. 2
0
        public IAsyncResult BeginLogin(AsyncCallback callback, string id, string password, object state = null)
        {
            var asyncResult = new NCAsyncResult(callback, state);
            var thr         = new Thread(() =>
            {
                asyncResult.SetCompleted(Login(id, password));
            });

            thr.IsBackground = true;
            thr.Start();
            return(asyncResult);
        }
Esempio n. 3
0
        public IAsyncResult BeginConnectOMCS(AsyncCallback callback, string serverIP, int serverPort, object state = null)
        {
            var asyncResult = new NCAsyncResult(callback, state);
            var thr         = new Thread(() =>
            {
                try
                {
                    ConnectOMCS(serverIP, serverPort);
                    asyncResult.SetCompleted(baseResult.Successful);
                }
                catch (Exception e)
                {
                    asyncResult.SetCompleted(baseResult.Faild, e.Message);
                }
            });

            thr.IsBackground = true;
            thr.Start();
            return(asyncResult);
        }