RevitTask.RunAsync() returns before Revit
See original GitHub issueThe await RevitTask.RunAsync() does not seem to wait for Revit to finish. In the below sample method, RevitTask.RunAsync() returns “Jimmy” before the Selection is set in the ActiveUiDocument. So my MessageBox shows “jimmy” before the selection is made. I’m not sure why this would be the case.
private async void SelectInRevit()
{
var myString = await RevitTask.RunAsync(
app =>
{
app.ActiveUIDocument.Selection.SetElementIds(SelectedFam.ElementIds);
return "jimmy";
});
MessageBox.Show($"{myString}");
}
Issue Analytics
- State:
- Created 5 months ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Running Revit asynchronously and updating form after task ...
In step 3 im capturing the RevitServices.application in a Shared static class, so I can use it later in the method app.OpenDocumentfile(). While ......
Read more >KennanChan/Revit.Async: Use task-based asynchronous ...
Async is exposed by RevitTask.RunAsync() method. There are multiple overloads for RevitTask.RunAsync() method. Execute sync code, without return value.
Read more >Another Async Await, REX + Structural Analysis SDK
A common solution for this exception is to wrap the Revit API code using IExternalEventHandler and register the handler instance to Revit ahead ......
Read more >Rhino Inside Revit limitation: IExternalEventHandler deadlock ...
In this case Grasshopper is synchronous, it needs to finish solving all the components in the canvas before returning control back. So without...
Read more >External Communication and Async Await Event
External Communication and Async Await Event. The question of communicating from outside with Revit is popping up with increasing frequency.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think I can close this issue. You can submit a new one if the issue persists.
You can try to write a pure external event handler to test the code to see if the issue still exists