Esempio n. 1
0
 public static SafeFrameLockExecutionResult ExecuteWithinFrameLock(Action action, bool updateActors = false)
 {
     var result = new SafeFrameLockExecutionResult { Success = true };
     FrameLock frameLock = null;
     var frameLockAcquired = false;
     if (!BotEvents.IsBotRunning)
     {
         Logger.Verbose("Acquiring Framelock");
         if (updateActors) ZetaDia.Actors.Update();
         frameLock = ZetaDia.Memory.AcquireFrame(true);
         frameLockAcquired = true;
     }
     try
     {
         action.Invoke();
     }
     catch (Exception ex)
     {
         result.Success = false;
         result.Exception = ex;
     }
     finally
     {
         if (frameLockAcquired)
         {
             Logger.Verbose("Releasing Framelock");
             frameLock.Dispose();
         }
     }
     return result;
 }
Esempio n. 2
0
        public static SafeFrameLockExecutionResult ExecuteWithinFrameLock(Action action, bool updateActors = false)
        {
            var result = new SafeFrameLockExecutionResult {
                Success = true
            };
            FrameLock frameLock         = null;
            var       frameLockAcquired = false;

            if (!BotEvents.IsBotRunning)
            {
                Logger.Verbose("Acquiring Framelock");
                if (updateActors)
                {
                    ZetaDia.Actors.Update();
                }
                frameLock         = ZetaDia.Memory.AcquireFrame(true);
                frameLockAcquired = true;
            }
            try
            {
                action.Invoke();
            }
            catch (Exception ex)
            {
                result.Success   = false;
                result.Exception = ex;
            }
            finally
            {
                if (frameLockAcquired)
                {
                    Logger.Verbose("Releasing Framelock");
                    frameLock.Dispose();
                }
            }
            return(result);
        }