/// <summary> /// Running Revit API code and get the result asynchronously /// </summary> /// <typeparam name="TResult">The type of the Result</typeparam> /// <param name="function"> /// The delegate method wraps all the Revit API code and some other asynchronous processes with /// <see cref="UIApplication" /> as argument /// </param> /// <returns></returns> public static Task <TResult> RunAsync <TResult>(Func <UIApplication, Task <TResult> > function) { var handler = new AsyncDelegateExternalEventHandler <TResult>(); var futureExternalEvent = new FutureExternalEvent(handler); return(futureExternalEvent.RunAsync <Func <UIApplication, Task <TResult> >, TResult>(function)); }
/// <summary> /// Always call this method ahead of time in Revit API context to make sure that <see cref="RevitTask" /> functions /// properly /// </summary> public static void Initialize(UIControlledApplication application) { FutureExternalEvent.Initialize(application); }