コード例 #1
0
ファイル: Service.cs プロジェクト: NucleusDE/NewTalking
        static public void ActiveService()
        {
            Thread tdChattingService_NO1 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
                
            });
            Thread tdChattingService_NO2 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO3 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO4 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });
            Thread tdChattingService_NO5 = new Thread(delegate () {
                Data_BLL bll = new Data_BLL();
                Receiver receiver = new Receiver();
                while (true)
                    bll.Analysis(receiver.ReceiveData());
            });

            Thread tdHeartBeat = new Thread(delegate ()
            {
                HeartBeat();
                Thread.Sleep(TimeSpan.FromSeconds(5));
            });

            tdChattingService_NO1.Start();
            tdChattingService_NO2.Start();
            tdChattingService_NO3.Start();
            tdChattingService_NO4.Start();
            tdChattingService_NO5.Start();

            tdHeartBeat.Start();
        }
コード例 #2
0
ファイル: Service.cs プロジェクト: NucleusDE/NewTalking
        static public void ActiveService()
        {
            Thread tdService = new Thread(delegate ()
            {
                GetClient getClient = new GetClient();
                while (true)
                {
                    TcpClient tcpClient = getClient.Get();

                    Thread tdClientService = new Thread(delegate ()
                    {
                        TcpClient tcpUser = tcpClient;

                        try
                        {
                            Data_BLL bll = new Data_BLL();
                            while (true)
                            {
                                Receiver receiver = new Receiver();
                                bll.Analysis(receiver.ReceiveData(tcpUser));
                            }
                        }
                        catch
                        {
                            //[未升级] 从已登录用户中删除
                            lock (Data.Data.ArrOnlineUsers)
                            {
                                ArrayList arrTemp = new ArrayList();
                                for (int i = 0; i < Data.Data.ArrOnlineUsers.Count; i++)
                                {
                                    OnlineUserProperties onlineUser = (OnlineUserProperties)Data.Data.ArrOnlineUsers[i];
                                    if (onlineUser.Client != tcpUser)
                                        arrTemp.Add(Data.Data.ArrOnlineUsers[i]);
                                }
                                Data.Data.ArrOnlineUsers = arrTemp;
                            }
                        }
                    });
                    tdClientService.Start();
                    ThreadPool.ArrServiceThreads.Add(tdClientService);
                }
            });
            tdService.Start();
        }