Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to check if Revit is busy!

5 REPLIES 5
Reply
Message 1 of 6
ricaun
315 Views, 5 Replies

How to check if Revit is busy!

ricaun
Advisor
Advisor

Recently I created and shared this package to monitor if Revit is busy doing something or not.

The code use Idling to update the IsRevitBusy propriety when the event stop triggering.

 

I would like to know if someone have a different approach with the same goal, to know if Revit is busy or available to run ExternalEvent.

 

In the past, the Revit API had IsQuiescent propriety, but it seems not thread-safe and was removed.

 

I kinda what something like IsQuiescent without messing with events.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

How to check if Revit is busy!

Recently I created and shared this package to monitor if Revit is busy doing something or not.

The code use Idling to update the IsRevitBusy propriety when the event stop triggering.

 

I would like to know if someone have a different approach with the same goal, to know if Revit is busy or available to run ExternalEvent.

 

In the past, the Revit API had IsQuiescent propriety, but it seems not thread-safe and was removed.

 

I kinda what something like IsQuiescent without messing with events.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

5 REPLIES 5
Message 2 of 6
jeremy_tammik
in reply to: ricaun

jeremy_tammik
Autodesk
Autodesk

I think the Idling event is problematic, because (I believe) Revit calls it as much as possible when it is not busy, consuming a lot of computer performance. Can you explain how this test is related to the API Context Predicate approach recently suggested by @nice3point , and why you cannot use that?

    

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

I think the Idling event is problematic, because (I believe) Revit calls it as much as possible when it is not busy, consuming a lot of computer performance. Can you explain how this test is related to the API Context Predicate approach recently suggested by @nice3point , and why you cannot use that?

    

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 6
nice3point
in reply to: ricaun

nice3point
Advocate
Advocate

Revit Idling similar to System.Windows.Interop.ComponentDispatcher.ThreadIdle is called extremely often, and without trottling it significantly degrades performance. Idling should be used in very specific cases when there are really no alternatives in RevitAPI and at the same time to unsubscribe as early as possible.

Displaying revit busy indicator in modeless windows even from the UX side looks strange. But if there is a need, you can use AsyncEventHandler in combination with TaskNotifier to bind the task progress to UI.

 

Sample: https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/mvvm/ObservableObject.md

Revit Idling similar to System.Windows.Interop.ComponentDispatcher.ThreadIdle is called extremely often, and without trottling it significantly degrades performance. Idling should be used in very specific cases when there are really no alternatives in RevitAPI and at the same time to unsubscribe as early as possible.

Displaying revit busy indicator in modeless windows even from the UX side looks strange. But if there is a need, you can use AsyncEventHandler in combination with TaskNotifier to bind the task progress to UI.

 

Sample: https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/mvvm/ObservableObject.md

Message 4 of 6
ricaun
in reply to: nice3point

ricaun
Advisor
Advisor

The code is doing the smallest thing inside the Idling event, and I would love to not use that event, but I don't know if there is a way with the requirement I have.

 

Could be used to make a modeless UI grey and unavailable, but is not what I'm using for.

 

I'm using Revit as service with my RevitTest Framework, and I need to know when Revit is available or free to be used, to make sure if I Raise the ExternalEvent the code gonna execute as soon as possible.

 

If any pop happen in Revit with the MessageBox.Show for example, Revit gonna be busy waiting for the user to close the message box.

 

How can I find the Revit availability/busy state without using Idling that basically trigger when Revit is available for user interactions.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

The code is doing the smallest thing inside the Idling event, and I would love to not use that event, but I don't know if there is a way with the requirement I have.

 

Could be used to make a modeless UI grey and unavailable, but is not what I'm using for.

 

I'm using Revit as service with my RevitTest Framework, and I need to know when Revit is available or free to be used, to make sure if I Raise the ExternalEvent the code gonna execute as soon as possible.

 

If any pop happen in Revit with the MessageBox.Show for example, Revit gonna be busy waiting for the user to close the message box.

 

How can I find the Revit availability/busy state without using Idling that basically trigger when Revit is available for user interactions.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 5 of 6
nice3point
in reply to: ricaun

nice3point
Advocate
Advocate
Should you then make this property Obsevable if you don't plan it for Binding? For tests it is enough to subscribe once and unsubscribe immediately when required. Another option is to use the ApplicationInitialized event, and run Revit in no-ui mode so you can't open any dialog. I've presented a few more options, but I don't know the intricacies of how you use this. To suppress Msbox use UiApplication.DialogBoxShowing event
0 Likes

Should you then make this property Obsevable if you don't plan it for Binding? For tests it is enough to subscribe once and unsubscribe immediately when required. Another option is to use the ApplicationInitialized event, and run Revit in no-ui mode so you can't open any dialog. I've presented a few more options, but I don't know the intricacies of how you use this. To suppress Msbox use UiApplication.DialogBoxShowing event
Message 6 of 6
ricaun
in reply to: nice3point

ricaun
Advisor
Advisor

@nice3point wrote:
Should you then make this property Obsevable if you don't plan it for Binding? For tests it is enough to subscribe once and unsubscribe immediately when required. Another option is to use the ApplicationInitialized event, and run Revit in no-ui mode so you can't open any dialog. I've presented a few more options, but I don't know the intricacies of how you use this. To suppress Msbox use UiApplication.DialogBoxShowing event

Eventually, I will use that appouch to Binding the UI to prevent the user to interact with the modeless windows UI.

 

Suppress the UI could be an option but is not what I'm looking for, my RevitTest Framework should not change the normal behavior of Revit.

 

Just want to know when Revit is busy or available. Without using Idling event is hard/impossible to find that Revit state.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes


@nice3point wrote:
Should you then make this property Obsevable if you don't plan it for Binding? For tests it is enough to subscribe once and unsubscribe immediately when required. Another option is to use the ApplicationInitialized event, and run Revit in no-ui mode so you can't open any dialog. I've presented a few more options, but I don't know the intricacies of how you use this. To suppress Msbox use UiApplication.DialogBoxShowing event

Eventually, I will use that appouch to Binding the UI to prevent the user to interact with the modeless windows UI.

 

Suppress the UI could be an option but is not what I'm looking for, my RevitTest Framework should not change the normal behavior of Revit.

 

Just want to know when Revit is busy or available. Without using Idling event is hard/impossible to find that Revit state.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report