/// <summary>Add a idle action.</summary> /// <param name="idleAction"></param> /// <returns></returns> public IPpsIdleAction AddIdleAction(IPpsIdleAction idleAction) { Dispatcher.VerifyAccess(); if (IndexOfIdleAction(idleAction) == -1) { idleActions.Add(new WeakReference <IPpsIdleAction>(idleAction)); } return(idleAction); } // proc AddIdleAction
private int IndexOfIdleAction(IPpsIdleAction idleAction) { for (var i = 0; i < idleActions.Count; i++) { if (idleActions[i].TryGetTarget(out var t) && t == idleAction) { return(i); } } return(-1); } // func IndexOfIdleAction
public void RemoveIdleAction(IPpsIdleAction idleAction) { if (idleAction == null) { return; } Dispatcher.VerifyAccess(); var i = IndexOfIdleAction(idleAction); if (i >= 0) { idleActions.RemoveAt(i); } } // proc RemoveIdleAction
private IPpsObjectDataAccess dataAccess; // access token to the data object #region -- Ctor/Dtor/Load/Unload ---------------------------------------------- /// <summary></summary> /// <param name="paneHost"></param> public PpsGenericMaskWindowPane(IPpsWindowPaneHost paneHost) : base(paneHost) { idleActionToken = Shell.AddIdleAction( elapsed => { if (elapsed > 3000) { if (data != null && data.IsDirty) { CommitEditAsync().AwaitTask(); } return(false); } else { return(data != null && data.IsDirty); } } ); } // ctor