mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-11-03 22:12:52 +00:00 
			
		
		
		
	预防闪退
This commit is contained in:
		
							parent
							
								
									a6fcf53b10
								
							
						
					
					
						commit
						ec3eb2215b
					
				
					 1 changed files with 23 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -35,25 +35,32 @@ namespace v2rayN.Base
 | 
			
		|||
 | 
			
		||||
        private void StartListen()
 | 
			
		||||
        {
 | 
			
		||||
            listener = new TcpListener(IPAddress.Any, port);
 | 
			
		||||
            listener.Start();
 | 
			
		||||
            Utils.SaveLog("WebserverB running...");
 | 
			
		||||
 | 
			
		||||
            while (true)
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                if (!listener.Pending())
 | 
			
		||||
                {
 | 
			
		||||
                    Thread.Sleep(100);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                listener = new TcpListener(IPAddress.Any, port);
 | 
			
		||||
                listener.Start();
 | 
			
		||||
                Utils.SaveLog("WebserverB running...");
 | 
			
		||||
 | 
			
		||||
                TcpClient socket = listener.AcceptTcpClient();
 | 
			
		||||
                Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread))
 | 
			
		||||
                while (true)
 | 
			
		||||
                {
 | 
			
		||||
                    IsBackground = true
 | 
			
		||||
                };
 | 
			
		||||
                thread.Start(socket);
 | 
			
		||||
                Thread.Sleep(1);
 | 
			
		||||
                    if (!listener.Pending())
 | 
			
		||||
                    {
 | 
			
		||||
                        Thread.Sleep(100);
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    TcpClient socket = listener.AcceptTcpClient();
 | 
			
		||||
                    Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread))
 | 
			
		||||
                    {
 | 
			
		||||
                        IsBackground = true
 | 
			
		||||
                    };
 | 
			
		||||
                    thread.Start(socket);
 | 
			
		||||
                    Thread.Sleep(1);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                Utils.SaveLog("WebserverB start fail.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        private void ProcessThread(object obj)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue