3028e9e29d
* First pass adding async * Updated Idle manager to work with async Tasks * CA1506 * missing async * Fixed tests * Really fixed tests * CA2201 * Really fixed the tests * remaining awaits * Async everywhere! * Fixed merge errors * fix: Missing imports * IProgress sync used * rename progress * format * Remove empty files * update sdk * convert progress * use FireAndForget and readonly struct * revert revit to use RevitTask * don't use sync to UI thread for progress * Fixes autocad loop to update UI with Task.Delay instead of Task.Yield * format * merge fixes * update nugets * fix imports for exceptions * fix import --------- Co-authored-by: Alan Rynne <alan@speckle.systems> Co-authored-by: Adam Hathcock <adam@hathcock.uk>
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using Speckle.InterfaceGenerator;
|
|
|
|
namespace Speckle.Connectors.DUI.Bridge;
|
|
|
|
[GenerateAutoInterface]
|
|
public abstract class AppIdleManager : IAppIdleManager
|
|
{
|
|
private readonly IIdleCallManager _idleCallManager;
|
|
|
|
protected AppIdleManager(IIdleCallManager idleCallManager)
|
|
{
|
|
_idleCallManager = idleCallManager;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Subscribe deferred action to Idling event to run it whenever Revit becomes idle.
|
|
/// </summary>
|
|
/// <param name="action"> Action to call whenever the host app becomes Idle.</param>
|
|
/// some events in host app are triggered many times, we might get 10x per object
|
|
/// Making this more like a deferred action, so we don't update the UI many times
|
|
public void SubscribeToIdle(string id, Action action)
|
|
{
|
|
_idleCallManager.SubscribeToIdle(id, action, AddEvent);
|
|
}
|
|
|
|
/// <inheritdoc cref="SubscribeToIdle(string,System.Action)"/>
|
|
public void SubscribeToIdle(string id, Func<Task> asyncAction)
|
|
{
|
|
_idleCallManager.SubscribeToIdle(id, asyncAction, AddEvent);
|
|
}
|
|
|
|
protected abstract void AddEvent();
|
|
}
|