public SleepWatch(uint interval) { mInterval = interval; mWatch = StopWatch.Create(StopWatch.TickStyles.Milliseconds); mWatch.Start(); }
public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); mTimer.Start(); do { mTimer.Restart(); while (mTimer != null && mTimer.GetElapsedTime() < mDelay) { if (Simulator.CheckYieldingContext(false)) { Simulator.Sleep(0u); } } if (!mFunction()) { Dispose(); break; } if (Simulator.CheckYieldingContext(false)) { Simulator.Sleep(0u); } }while (mTimer != null); }
public override void Simulate() { try { //NRaas.SpeedTrap.Begin(); mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); mTimer.Start(); while (true) { mTimer.Restart(); try { while ((mTimer != null) && (mTimer.GetElapsedTime() < Delay)) { Common.Sleep(); } if (!OnPerform()) { Stop(); return; } Common.Sleep(); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception("Simulate", exception); } if (mTimer == null) { return; } } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception("Simulate", e); } finally { OnPostSimulate(); //NRaas.SpeedTrap.End(); } }
public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); if (mTimer == null) { Dispose(); return; } if (shouldRun) { Dispose(); return; } shouldRun = true; mTimer.Start(); do { if (GameUtils.IsPaused()) { Simulator.Sleep(0); mTimer.Stop(); } else { if (GameUtils.IsPaused()) { Simulator.Sleep(0); continue; } mTimer.Restart(); while (mTimer != null && mTimer.GetElapsedTime() < mDelay) { Simulator.Sleep(0); } mFunction(mParam); Simulator.Sleep(0); } }while (mTimer != null); }
private int TimedExecuteNonQuery(IDbCommand cmd) { StopWatch sw = StopWatch.Create(); try { sw.Start(); int retval = cmd.ExecuteNonQuery(); sw.Stop(); return(retval); } catch (Exception ex) { sw.Stop(); if (sqllogger.IsErrorEnabled) { sqllogger.Error("Error while executing: {0}\nException: {1}", LogCommand(cmd), ex); } throw ex; } finally { double timeInSeconds = sw.Seconds; if (Statistics != null) { Statistics.RegisterQueryTime(timeInSeconds); } SoodaStatistics.Global.RegisterQueryTime(timeInSeconds); if (timeInSeconds > QueryTimeTraceWarn && sqllogger.IsWarnEnabled) { sqllogger.Warn("Non-query time: {0} ms. {1}", Math.Round(timeInSeconds * 1000.0, 3), LogCommand(cmd)); } else if (timeInSeconds > QueryTimeTraceInfo && sqllogger.IsInfoEnabled) { sqllogger.Info("Non-query time: {0} ms. {1}", Math.Round(timeInSeconds * 1000.0, 3), LogCommand(cmd)); } else if (sqllogger.IsTraceEnabled) { sqllogger.Trace("Non-query time: {0} ms.{1}", Math.Round(timeInSeconds * 1000.0, 3), LogCommand(cmd)); } } }
public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); if (mTimer == null) { Dispose(); return; } if (shouldRun) { Dispose(); return; } shouldRun = true; mTimer.Start(); while (true) { if (mTimer != null && mTimer.GetElapsedTime() == mDelay) { mFunction(mParam); Simulator.Sleep(0); continue; } Simulator.Sleep(0); if (mTimer == null) { break; } } }
public override bool Run() { try { if (!TimePortal.sTimeTravelerHasBeenSummoned && Actor.CreateRoute().PlanToSlot(Target, Slot.RoutingSlot_0).Succeeded()) { if (!TimeTravelerSituation.Create(Actor.LotHome, Actor.ObjectId, Target.ObjectId)) { return(false); } CauseEffectService.OpportunityPortal = Target; mTimeTravlerArrivalHandled = false; } if ((Target.InUse && !Target.IsActorUsingMe(Actor)) || !Actor.RouteToSlot(Target, Slot.RoutingSlot_0, false)) { return(false); } if (Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { return(false); } Definition interactionDefinition = InteractionDefinition as Definition; if (Target.Active) { interactionDefinition.curState = TimePortal.PortalState.Active; } else { interactionDefinition.curState = TimePortal.PortalState.Inactive; } Actor.SkillManager.AddElement(SkillNames.Future); StandardEntry(!Target.IsActorUsingMe(Actor)); BeginCommodityUpdates(); Target.mTimeToStepBack = false; EnterStateMachine("timeportal", "Enter", "x"); SetActor("portal", Target); mCurrentStateMachine.AddOneShotScriptEventHandler(0x65, SwitchActiveState); mCurrentStateMachine.AddOneShotScriptEventHandler(0x66, PositionTimeTraveler); AnimateSim("Mess With"); if (!TimePortal.sTimeTravelerHasBeenSummoned) { Common.DebugNotify("A"); mCurrentStateMachine.RequestState(false, "x", "FirstTimeReact"); emergencyStopWatch = StopWatch.Create(StopWatch.TickStyles.Seconds); int num = 0x2d; mTimeTraveler = CauseEffectService.GetInstance().GetTimeTraveler(); while ((mTimeTraveler == null) && (emergencyStopWatch.GetElapsedTime() < num)) { SpeedTrap.Sleep(0x1); // Custom SimDescription simDesc = SimDescription.Find(CauseEffectService.sPersistableData.TimeTravelerSimID); if (simDesc == null) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; CauseEffectService.GetInstance().RequestTimeTravelerSimDesc(Household.NpcHousehold); } else { mTimeTraveler = Instantiation.PerformOffLot(simDesc, Target.LotCurrent, null); } } Common.DebugNotify("B"); if (mTimeTraveler != null) { InteractionQueue interactionQueue = mTimeTraveler.InteractionQueue; mLinkedInteraction = TimePortal.BeSummoned.Singleton.CreateInstance(Actor, mTimeTraveler, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, false) as TimePortal.BeSummoned; mLinkedInteraction.SyncTarget = Actor; interactionQueue.AddNext(mLinkedInteraction); Actor.SynchronizationRole = Sim.SyncRole.Initiator; Actor.SynchronizationTarget = mTimeTraveler; Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (Actor.WaitForSynchronizationLevelWithSim(mTimeTraveler, Sim.SyncLevel.Started, 40f)) { Common.DebugNotify("C"); SetActorAndEnter("y", mTimeTraveler, "TTEnter"); AnimateJoinSims("TimeTravelerExit"); Actor.SynchronizationLevel = Sim.SyncLevel.Completed; TimeTravelerSituation situation = ServiceSituation.FindServiceSituationInvolving(mTimeTraveler) as TimeTravelerSituation; if (situation != null) { situation.OnAppearComplete(mTimeTraveler, 0f); while (!Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { Actor.LoopIdle(); SpeedTrap.Sleep(0xa); } } else { Target.ActorsUsingMe.Clear(); TimePortal.sTimeTravelerHasBeenSummoned = true; } } else { AnimateSim("Exit"); } Common.DebugNotify("D"); mTimeTravlerArrivalHandled = true; } else { AnimateSim("Exit"); } } else { if (!GameUtils.IsFutureWorld()) { MiniSimDescription simDesc = MiniSimDescription.Find(CauseEffectService.sPersistableData.TimeTravelerSimID); if (simDesc == null) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; CauseEffectService.GetInstance().RequestTimeTravelerSimDesc(Household.NpcHousehold); } } AnimateSim("Exit"); Vector3 v = Target.Position + ((Vector3)(2f * Target.ForwardVector)); Actor.RouteToPoint(v); Actor.RouteTurnToFace(Target.Position); } EndCommodityUpdates(true); StandardExit(); if (Target.Active) { EventTracker.SendEvent(EventTypeId.kInspectedTimePortal, Actor); } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } finally { TravelUtil.PlayerMadeTravelRequest = false; //Sims3.Gameplay.Gameflow.Singleton.EnableSave(this); } return(false); }
public override void Simulate() { try { NRaas.SpeedTrap.Begin(); mTimer = StopWatch.Create(StopWatch.TickStyles.Minutes); mTimer.Start(); while (true) { while ((mTimer != null) && (mTimer.GetElapsedTime() < mSaveInterval)) { if (mExit) { break; } SpeedTrap.Sleep(); } if (mTimer == null) { break; } Corrections.CorrectSaveGameLocks(); do { if (mExit) { break; } SpeedTrap.Sleep(); }while (!IsValidState()); if (mExit) { break; } Saver.Save(); mTimer.Restart(); } Destroy(); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception("Simulate", exception); } finally { NRaas.SpeedTrap.End(); } }