调整代码
This commit is contained in:
19
ShrlAlgoToolkit.RevitCore/Base/ExternalEventHelper.cs
Normal file
19
ShrlAlgoToolkit.RevitCore/Base/ExternalEventHelper.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user