コード例 #1
0
ファイル: WowLockToken.cs プロジェクト: sergius-dart/HBRelog
		public static WowLockToken RequestLock(WowManager wowManager, out string reason)
		{
			reason = string.Empty;
			WowLockToken ret;
			string key = wowManager.Settings.WowPath.ToUpper();
			lock (LockObject)
			{
				var now = DateTime.Now;
				bool throttled = now - _lastLockTime < TimeSpan.FromSeconds(HbRelogManager.Settings.WowDelay);
				if (throttled)
				{
					reason = "Waiting to start WoW";
					return null;
				}

				if (LockInfos.ContainsKey(key))
				{
					var lockInfo = LockInfos[key];
					var locked = lockInfo._lockOwner != null && lockInfo._lockOwner != wowManager;
					if (locked)
					{
						reason = string.Format("Waiting on profile: {0} to release lock", lockInfo._lockOwner.Profile.Settings.ProfileName);
						return null;
					}
				}
				_lastLockTime = now;
				ret = LockInfos[key] = new WowLockToken(key, DateTime.Now, wowManager);
			}
			return ret;
		}
コード例 #2
0
ファイル: WowLockToken.cs プロジェクト: NN91/HBRelog
        public static WowLockToken RequestLock(WowManager wowManager, out string reason)
        {
            reason = string.Empty;
            WowLockToken ret;
            string key = wowManager.Settings.WowPath.ToUpper();
            lock (LockObject)
            {
                var now = DateTime.Now;
                bool throttled = now - _lastLockTime < TimeSpan.FromSeconds(HbRelogManager.Settings.WowDelay);
                if (throttled)
                {
                    reason = "Waiting to start WoW";
                    return null;
                }

                if (LockInfos.ContainsKey(key))
                {
                    var lockInfo = LockInfos[key];
                    var locked = lockInfo._lockOwner != null && lockInfo._lockOwner != wowManager;
                    if (locked)
                    {
                        reason = string.Format("Waiting on profile: {0} to release lock", lockInfo._lockOwner.Profile.Settings.ProfileName);
                        return null;
                    }
                }
                _lastLockTime = now;
                ret = LockInfos[key] = new WowLockToken(key, DateTime.Now, wowManager);
            }
            return ret;
        }