Ejemplo n.º 1
0
        protected void ScanMailProc(object sender)
        {
            try
            {
                int startTick = Environment.TickCount;
                if (log.IsInfoEnabled)
                {
                    log.Info("Saving Record...");
                    log.Debug("Save ThreadId=" + Thread.CurrentThread.ManagedThreadId);
                }

                ThreadPriority oldprio = Thread.CurrentThread.Priority;
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;

                string noticeUserID = "";
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    db.ScanMail(ref noticeUserID);
                }
                string[] userIDs = noticeUserID.Split(',');

                foreach (string s in userIDs)
                {
                    if (string.IsNullOrEmpty(s))
                        continue;
                    GSPacketIn pkg = new GSPacketIn((byte)ePackageType.MAIL_RESPONSE);
                    pkg.WriteInt(int.Parse(s));
                    pkg.WriteInt((int)eMailRespose.Receiver);
                    SendToALL(pkg);
                }

                Thread.CurrentThread.Priority = oldprio;

                startTick = Environment.TickCount - startTick;
                if (log.IsInfoEnabled)
                {
                    log.Info("Scan Mail complete!");
                }
                if (startTick > 2 * 60 * 1000)
                {
                    log.WarnFormat("Scan all Mail in {0} ms", startTick);
                }
            }
            catch (Exception e1)
            {
                if (log.IsErrorEnabled)
                    log.Error("ScanMailProc", e1);
            }
        }