public override void OnUserInput(object value) { if (NotificationGate.IsInbound) { var scheduler = UpdateScheduler.Begin(); try { if (_hasChildObject && value != null) { value = ((IObjectInstance)value).WrappedObject; } ClassProperty.SetObjectValue(ObjectInstance.WrappedObject, value); } finally { if (scheduler != null) { using (NotificationGate.BeginOutbound()) { foreach (Action updatable in scheduler.End()) { updatable(); } } } } } }
private void TextViewTextChanged(object sender, EventArgs e) { if (_outputCount > 0) { return; } var updateScheduler = UpdateScheduler.Begin(); try { _input(_converter.ConvertInput(_control.Text)); } finally { if (updateScheduler != null) { _inputCount++; try { foreach (var update in updateScheduler.End()) { update(); } } finally { _inputCount--; } } } }
public DependentCollection(Func <IEnumerable <T> > getMethod) { _getMethod = getMethod; _depCollection = new Dependent(OnUpdateCollection); _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(this); _depCollection.Touch(); }
public override void OnUserInput(object value) { if (NotificationGate.IsInbound) { var scheduler = UpdateScheduler.Begin(); try { value = TranslateIncommingValue(value); ClassProperty.SetObjectValue(ObjectInstance.WrappedObject, value); } finally { if (scheduler != null) { using (NotificationGate.BeginOutbound()) { foreach (IUpdatable updatable in scheduler.End()) { updatable.UpdateNow(); } } } } } }
public override View GetView(int position, View convertView, ViewGroup parent) { var itemContainer = GetItem(position); if (itemContainer.View != null) { return(itemContainer.View); } var inflater = (LayoutInflater)Context.GetSystemService( Context.LayoutInflaterService); var row = inflater.Inflate(_resourceId, parent, attachToRoot: false); var scheduler = UpdateScheduler.Begin(); try { _bind(row, itemContainer.Item, itemContainer.Bindings); } finally { if (scheduler != null) { foreach (var update in scheduler.End()) { update(); } } } itemContainer.View = row; return(row); }
public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty) : base(objectInstance, classProperty) { if (ClassProperty.CanRead) { // When the property is out of date, update it from the wrapped object. _depProperty = new Dependent(delegate { object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject); value = TranslateOutgoingValue(value); if (!Object.Equals(_value, value)) { _value = value; } if (_firePropertyChanged) { ObjectInstance.FirePropertyChanged(ClassProperty.Name); } _firePropertyChanged = true; }); // When the property becomes out of date, trigger an update. // The update should have lower priority than user input & drawing, // to ensure that the app doesn't lock up in case a large model is // being updated outside the UI (e.g. via timers or the network). _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this); } }
public ComputedCollection(Func <IEnumerable <T> > getMethod) { _getMethod = getMethod; _depCollection = new Computed(OnUpdateCollection); _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); _depCollection.Touch(); }
/// <returns>true to cancel</returns> protected virtual bool OnExitRequested() { if (ExitRequested) { return(false); } bool?response = null; UpdateScheduler.Add(delegate { response = Exiting?.Invoke() == true; }); //wait for a potentially blocking response while (!response.HasValue) { Thread.Sleep(1); } if (response.Value) { return(true); } Exit(); return(false); }
private void Computed_Invalidated() { UpdateScheduler.ScheduleUpdate(delegate() { _priorState = _update(_priorState); }); }
private void Invalidated() { // When the "can execute" flag is invalidated, we need to queue // up a call to update it. This will cause the UI thread to // call TriggerUpdate (below) when everything settles down. UpdateScheduler.ScheduleUpdate(this); }
public void Update(float deltaSeconds) { if (IsPlaying) { UpdateScheduler.Update(deltaSeconds, EUpdatePriority.ResourceLoading, EUpdatePriority.PrePhysics); PhysicsWorld.Update(deltaSeconds); UpdateScheduler.Update(deltaSeconds, EUpdatePriority.PostPhysics, EUpdatePriority.Latest); } else { UpdateScheduler.Update(deltaSeconds, EUpdatePriority.Editor, EUpdatePriority.ResourceLoading); } GameConsole.Draw(ViewManager.ScreenWidth, ViewManager.ScreenHeight); ViewManager.GetViewInfo(out SSceneViewInfo viewInfo); #region MenuBar m_performanceCounter.UpdateFrametime(deltaSeconds); ImGui.BeginMainMenuBar(); ImGui.Text("FPS: " + (1 / m_performanceCounter.SmoothedFrametime).ToString("n2")); ImGui.Text(string.Format("CameraPosition X: {0:0.00} Y: {1:0.00} Z: {2:0.00}", viewInfo.ViewLocation.X, viewInfo.ViewLocation.Y, viewInfo.ViewLocation.Z)); ImGui.EndMainMenuBar(); #endregion CRenderer.Instance.ActiveScene.UpdateViewInfo(in viewInfo); for (int i = 0; i < m_pendingDestroyEntities.Count; i++) { InternalDestroyEntity(m_pendingDestroyEntities[i]); } m_pendingDestroyEntities.Clear(); }
private void Update() { if (UpdateScheduler == null) { UpdateScheduler = new UnityTaskScheduler("Update"); } UpdateScheduler.Activate(); }
public Tree() { _depNodes = new Dependent(delegate { _root.UpdateNodes(); }); _depNodes.Invalidated += () => UpdateScheduler.ScheduleUpdate(this); }
public Tree() { _depNodes = new Computed(delegate { _root.UpdateNodes(); }); _depNodes.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); }
public async Task <ResponseData> UpDataScheduler(string id, UpdateScheduler updateScheduler) { var Result = _verificationUpdateSchedulerData.Validate(updateScheduler); ITrigger trigger; if (!Result.IsValid) { return(new ResponseData(Result.ToString(), "", StatusCode.Fail)); } var selectData = await _Database.SingleAsync <DataBaseScheduler>("where id = @0", id); if (string.IsNullOrEmpty(selectData.Interval) && selectData.ExecuteReuslt == 1) { return(new ResponseData("非循环任务不能进行修改", "", StatusCode.Fail)); } //暂停任务 await scheduler.PauseJob(new JobKey(updateScheduler.Name)); var job = await scheduler.GetJobDetail(new JobKey(updateScheduler.Name)); await scheduler.UnscheduleJob(new TriggerKey(updateScheduler.Name)); // 取消触发器 // 检查更改的数据是否有间隔时间 if (string.IsNullOrEmpty(updateScheduler.Interval)) { trigger = TriggerBuilder.Create() .WithIdentity(updateScheduler.Name) .StartAt(Convert.ToDateTime(updateScheduler.PresetTime)) .Build(); } else { var arryDate = ConversionTime.ChangeInterval(updateScheduler.Interval); TimeSpan timeSpan = new TimeSpan(arryDate[0], arryDate[1], arryDate[2], arryDate[3]); trigger = TriggerBuilder.Create() .WithIdentity(updateScheduler.Name) .WithSimpleSchedule(x => x.WithInterval(timeSpan).RepeatForever()) .StartAt(Convert.ToDateTime(updateScheduler.PresetTime)) .Build(); } // 把任务和触发器绑定 await scheduler.ScheduleJob(job, trigger); Sql sql = new Sql(); sql.Set("PresetTime = @0, Interval = @1", updateScheduler.PresetTime, updateScheduler.Interval) .Where("id = @0", id); if (await _Database.UpdateAsync <DataBaseScheduler>(sql) < 0) { return(new ResponseData("修改失败", "", StatusCode.Fail)); } // 重启任务 await scheduler.ResumeJob(new JobKey(updateScheduler.Name)); return(new ResponseData("修改成功", "", StatusCode.Success)); }
public void Initialize() { if (_updateQueue == null) { _updateQueue = new Queue <Action>(); UpdateScheduler.Initialize(a => _updateQueue.Enqueue(a)); } _updateQueue.Clear(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // запуск выполнения работы UpdateScheduler.Start(); }
public static void Initialize() { // Ensure that the UpdateScheduler has the ability to run delegates // on the UI thread. if (_mainDispatcher == null) { _mainDispatcher = Window.Current.Dispatcher; } UpdateScheduler.Initialize(RunOnUIThread); }
public MethodCommand(object instance, CommandMeta meta) { Instance = instance; Meta = meta; if (meta.Condition != null) { _computedCan = new Computed <bool>(() => (bool)meta.Condition.GetValue(Instance)); _computedCan.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); } }
/// <summary> /// Initialize the binding manager for an activity. /// </summary> /// <param name="bindings">The binding manager for the activity.</param> /// <param name="activity">The activity that owns the binding manager.</param> public static void Initialize(this BindingManager bindings, Activity activity) { UpdateScheduler.Initialize(action => { ThreadPool.QueueUserWorkItem(delegate(Object obj) { activity.RunOnUiThread(action); }); }); }
protected override void LoadGame(BaseGame game) { //delay load until we have a size. if (Size == Vector2.Zero) { UpdateScheduler.Add(delegate { LoadGame(game); }); return; } base.LoadGame(game); }
public static Dependent WhenNecessary(Action updateMethod) { var dependent = new Dependent(updateMethod); Update update = new Update(dependent); dependent.Invalidated += delegate { UpdateScheduler.ScheduleUpdate(update); }; dependent.OnGet(); return(dependent); }
public ObjectPropertyAtom(IObjectInstance objectInstance, ClassMember classProperty) : base(objectInstance, classProperty) { if (ClassProperty.CanRead) { // When the property is out of date, update it from the wrapped object. _depProperty = new Dependent(() => BindingInterceptor.Current.UpdateValue(this)); // When the property becomes out of date, trigger an update. // The update should have lower priority than user input & drawing, // to ensure that the app doesn't lock up in case a large model is // being updated outside the UI (e.g. via timers or the network). _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this); } }
private void window_ClientSizeChanged(object sender, EventArgs e) { if (Window.WindowState == WindowState.Minimized) { return; } var size = Window.ClientSize; UpdateScheduler.Add(delegate { //set base.Size here to avoid the override below, which would cause a recursive loop. base.Size = new Vector2(size.Width, size.Height); }); }
protected MemberSlot(ViewProxy proxy, MemberMeta member) { Proxy = proxy; Member = member; if (member.CanRead) { // When the property is out of date, update it from the wrapped object. _computed = new Computed(() => BindingInterceptor.Current.UpdateValue(this)); // When the property becomes out of date, trigger an update. // The update should have lower priority than user input & drawing, // to ensure that the app doesn't lock up in case a large model is // being updated outside the UI (e.g. via timers or the network). _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow); } }
static public UpdateScheduler Setup(UpdateScheduler scheduler) { AddSequence(scheduler) .BeginWith <PositionBinding>() .Then <ITrajectoryPlayer>() .Then <MotorBase>() .Then <Motion>() .Then <SpriteAnimator>() .Then <SongPlayer>() .Then <ICollider>() .Then <Actor>(); return(scheduler); }
public void Execute(object parameter) { var scheduler = UpdateScheduler.Begin(); try { BindingInterceptor.Current.Execute(this, parameter); } finally { if (scheduler != null) { foreach (var updatable in scheduler.End()) { updatable(); } } } }
public override void SetValue(object value) { var scheduler = UpdateScheduler.Begin(); try { value = UnwrapValue(value); Member.SetValue(Instance, value); } finally { if (scheduler != null) { foreach (Action updatable in scheduler.End()) { updatable(); } } } }
protected override void SetValue(object value) { var scheduler = UpdateScheduler.Begin(); try { value = TranslateIncommingValue(value); ClassProperty.SetObjectValue(ObjectInstance.WrappedObject, value); } finally { if (scheduler != null) { foreach (IUpdatable updatable in scheduler.End()) { updatable.UpdateNow(); } } } }
public void Execute(object parameter) { var scheduler = UpdateScheduler.Begin(); try { // Execute the command. _execute(); } finally { if (scheduler != null) { foreach (var updatable in scheduler.End()) { updatable.UpdateNow(); } } } }