Ejemplo n.º 1
0
        void TimerCallback(object state)
        {
            if (Interlocked.CompareExchange(ref _isTimmerCallbacking, 1, 1) == 1)
            {
                return;
            }

            try
            {
                LogInfo("begin check online state.");
                _onlineCheckBll.Check(checksSate =>
                {
                    LogInfo("check online state, OnlineState:{0}.", checksSate);

                    switch (checksSate)
                    {
                    case OnlineCheckState.CannotConnectServer:
                        LogInfo("Cannot Connect Server!");
                        break;

                    case OnlineCheckState.InvalidOpt:
                        if (Global.ApplicationData.User != null)
                        {
                            _userBll.ReLogin(new LoginInfo
                            {
                                User       = Global.ApplicationData.User,
                                UpdateInfo = Global.ApplicationData.UpdateInfo
                            }, loginState =>
                            {
                                LogInfo("ReLogin to server, LoginState:{0}.", loginState);
                            });
                        }
                        break;

                    case OnlineCheckState.Successed:
                    case OnlineCheckState.Failed:
                        break;
                    }
                });
            }
            catch (Exception ex)
            {
                LogError("Check online state Error.", ex);
            }
            finally
            {
                LogInfo("end check online state.");
                Interlocked.Exchange(ref _isTimmerCallbacking, 0);
            }
        }