Beispiel #1
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="obj"></param>
        private static void ReceiveMessage(object obj)
        {
            var serviceSocket = (Socket)obj;

            while (true)
            {
                try
                {
                    //通过clientSocket接收数据
                    var receiveNumber = serviceSocket.Receive(Result);
                    var receive       = Encoding.ASCII.GetString(Result, 0, receiveNumber);
                    Log4Helper.DebuggerLog(string.Format("接收客户端:{0},消息:{1}", serviceSocket.RemoteEndPoint, receive));
                    if (_func != null)
                    {
                        string result = _func(receive);
                        serviceSocket.Send(Encoding.ASCII.GetBytes(result));
                    }
                    if (!_cancellationToken.IsCancellationRequested)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorLog(ex.Message);
                    break;
                }
            }
            serviceSocket.Shutdown(SocketShutdown.Both);
            serviceSocket.Close();
            Dispose();
        }
Beispiel #2
0
        public async Task <ActionResult> Index()
        {
            for (int i = 0; i < 1000000; i++)
            {
                Log4Helper.InfoLog("hello");
                Log4Helper.ErrorLog("hello");
            }

            var user = await _UserManager.FindByIdAsync(User.Identity.GetUserId());

            return(View());
        }