IdlingEvent Problem

IdlingEvent Problem

Anonymous
Not applicable
915 Views
1 Reply
Message 1 of 2

IdlingEvent Problem

Anonymous
Not applicable

I am trying to implement Idling event, anyway when i debug the codes, looks like program cant finished every line in this function where it stop at this line:

 

UIApplication uiapp = new UIApplication(app);

Below is the Idling function:

 

        void OnIdling(object sender, IdlingEventArgs ea) {
            Application app = sender as Application;
            UIApplication uiapp = new UIApplication(app);   //debug stop here
            UIDocument uidoc = uiapp.ActiveUIDocument;      //debug never reach this line
            Document doc = uidoc.Document;
        }

Anybody understand why? Is my Revit idle cycle time too short? If yes how to control idle cycle time?

0 Likes
Accepted solutions (1)
916 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk
Accepted solution

You cannot control the Idling cycle time, unfortunately.

 

Afaik, Revit calls the Idling event as often as it possibly can, which may affect system performance.

 

Therefore, in most cases, I prefer using an external event.

 

I only use the Idling event if I want to be notified once only, as soon as possible, and then unsubscribe from it again.

 

Here is a description of switching from the older Idling event to the more modern external event:

 

http://thebuildingcoder.typepad.com/blog/2013/12/replacing-an-idling-event-handler-by-an-external-ev...

 

With the latter, I can control the polling frequency myself.

 

For simple official minimal samples of using these two, check out the two ModelessDialog samples in the Revit SDK.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder