コード例 #1
0
 public void ShowLockState(LockKey lockKey, bool state)
 {
     if ((lockKey == LockKey.Num && showNum) ||
         (lockKey == LockKey.Caps && showCaps) ||
         (lockKey == LockKey.Scroll && showScroll))
     {
         ShowMessage(lockKey.ToString() + ": " + (state ? "On" : "Off"));
     }
 }
コード例 #2
0
ファイル: LockAction.cs プロジェクト: wuhaiying83/QueueSystem
 public static void Run(LockKey key, Action action)
 {
     using (var db = Factory.Instance.CreateDbContext())
     {
         try
         {
             db.Session.CommandTimeout = 60;
             db.Session.BeginTransaction();
             db.Session.ExecuteScalar(@"
             select `key` from t_lock where `key` = @key FOR UPDATE;",
                                      new DbParam[] { new DbParam("key", key.ToString()) });
             action();
             db.Session.CommitTransaction();
         }
         catch (Exception ex)
         {
             db.Session.RollbackTransaction();
             throw ex;
         }
     }
 }