日期:2014-05-17  浏览次数:20567 次

C#异步报错。。
/// <summary>
        /// 日常日志记录
        /// </summary>
        /// <param name="LogModel"></param>
        public void AddLog(string logMsg, DateTime? opertionTime, DateTime? responseTime)
        {
            try
            {
                AsyncAddLog asy = new AsyncAddLog(AddLogdele);
                IAsyncResult ia = asy.BeginInvoke(logMsg, opertionTime, responseTime, new AsyncCallback(CallbackMethodAddLog), asy);
            }
            catch { }
        }

        private void AddLogdele(string logMsg, DateTime? opertionTime, DateTime? responseTime)
        {
            if (ConfigurationManager.AppSettings["LogSwitch"] != null && ConfigurationManager.AppSettings["LogSwitch"] == "on")
            {
                BasePage basePage = new BasePage();
                int userID = basePage.CurrentUser.UserID;
                string userName = basePage.CurrentUser.LoginName;
                string bussinessName = "123"; //base.CurrentModule.FULLNAME;
                DateTime recordTime = DateTime.Now;
                string com_Code = string.Empty;
                if (ConfigurationManager.AppSettings["Com_Code"] != null)
                {
                    com_Code = ConfigurationManager.AppSettings["Com_Code"].ToString();
                }
                HttpRequest Request = HttpContext.Current.Request;
                string client_IP = Request.ServerVariables.Get("Remote_Addr").ToString();
                DateTime opertionTimes = DateTime.