static int Max_Keep_Time = int.Parse(System.Configuration.ConfigurationManager.AppSettings["SetCheckOutTime"]);
        //const int Max_Keep_Time = 1;
        static AccountStatusInfoWS()
        {
            if (Max_Keep_Time < 0)
            {
                Max_Keep_Time = 1;
            }
            //间隔刷新时间为保持时间
            //double interval = 60 * 1000;
            int inter = Max_Keep_Time * 60 * 1000;
            //double interval =double.Parse( (Max_Keep_Time * 60 * 1000).ToString());
            //time = new System.Timers.Timer(Max_Login_Count * 60 * 1000);
            time = new System.Timers.Timer(inter);
            time.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
        }
        public AccountStatusInfoWS()
        {
            WSHelper.AuthenConnect(this.Context).ToString();
        }
        /// <summary>
        /// 时钟设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            time.Stop();
           // bool WsFlag = false;
            try
            {
                int index = 0;
                lock (BillAccountList)
                {
                    while (index < BillAccountList.Count)
                    {
                        //if (BillAccountList.Count > Max_Login_Count)
                        //{
                        //    SetNull(index);
                        //    continue;
                        //}
                        //else if (BillAccountList[index]._LoginTime.AddMinutes(Max_Keep_Time) <= DateTime.Now)
                        if (BillAccountList[index]._LoginTime.AddMinutes(Max_Keep_Time) <= DateTime.Now)
                        {
                            BillAccountList.RemoveAt(index);
                        }
                    }
                    index++;
                }
                //WsFlag = true;
                HotelUtility.LogMessage("ABC");
            }
            catch (Exception ex)
            {
                HotelUtility.LogException(ex,ex.Message);
            }
            time.Start();
            //return WsFlag;
        }
这样写有什么不对吗?
为什么我的日志无内容?
BillAccountList里面内容我在客户端看到的是一只存在,并未移除呢?
求大哥大姐们了。小弟实在是无奈!

解决方案 »

  1.   

    哈哈。。你的time没有Start。。哈哈。找个地方启动一下先。。呵呵。
    这么简单的问题让我逮到了。。
      

  2.   

    下面不是start了吗?高人,请具体指明在哪里加,好吗?谢谢了,现在搞的头痛!
    我在
    time = new System.Timers.Timer(inter); 
                time.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); 
    下面加上time.enable=true;相当于start了吗?
    谢谢了,
    很是着急!
    要辞职了。!
      

  3.   

    嗯。Enable应该是同等效果的。你试试看呗。。