20 lines
641 B
C#
20 lines
641 B
C#
namespace ShrlAlgoToolkit.RevitCore.Base
|
|
{
|
|
// 全局静态调用类
|
|
public static class ExternalEventHelper
|
|
{
|
|
private static ActionEventHandler _handler;
|
|
|
|
// 在 BaseApplication 的 OnStartup 中调用
|
|
public static void Initialize()
|
|
{
|
|
if (_handler == null)
|
|
_handler = new ActionEventHandler();
|
|
}
|
|
|
|
// 给 WPF 外部直接调用的入口
|
|
public static Task InvokeAsync(Action<UIApplication> action) => _handler.RaiseAsync(action);
|
|
public static Task<T> InvokeAsync<T>(Func<UIApplication, T> func) => _handler.RaiseAsync(func);
|
|
}
|
|
}
|