question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RevitTask.RunAsync() returns before Revit

See original GitHub issue

The 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:closed
  • Created 5 months ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KennanChancommented, May 26, 2023

I think I can close this issue. You can submit a new one if the issue persists.

0reactions
KennanChancommented, Apr 25, 2023

You can try to write a pure external event handler to test the code to see if the issue still exists

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found