Can you chain Idling events?

Can you chain Idling events?

ariWZRFQ
Enthusiast Enthusiast
4,250 Views
22 Replies
Message 1 of 23

Can you chain Idling events?

ariWZRFQ
Enthusiast
Enthusiast

Is it possible to chain Idling events?

 

Say I have two functions, FuncA and FuncB. I want to run FuncA the first time revit idles, then run FuncB after FuncA is done running and revit idles again. Inside my FuncA handler, I am removing the handler to FuncA from UIApp.Idling, but I can not assign a new handler because I don't have a valid API context.

 

Is there a way for me to achieve my intended behavior?

 

NOTE: The reason I'm doing any of this at all is because of this referenced post. For some reason, Revit throws an internal exception if my FuncA and FuncB are called one after the other. So I am separating them with an idling event. Now I need to add another idling event before FuncA.

0 Likes
4,251 Views
22 Replies
Replies (22)
Message 21 of 23

ariWZRFQ
Enthusiast
Enthusiast

Thanks for the reply and sorry for my own delay.

 

I already have the Revit.Async Initialized in the .OnStartup Method of the IExternalApplication with RevitTask.Initialize(application); where application is the UIControlledApplication that is passed into the OnStartup() method.

 

I still don't understand why my code from my previous reply isn't working. It seems like it should be based on my understanding from this thread and the Revit.Async Docs.

 

The only thing I could think is that since the return Autodesk.Revit.UI.Result.Succeeded; is being called likely before any of the tasks have returned in my func1, func2, and func3, I have lost the valid Revit context before the worker threads can do the revit tasks? Really just guessing now

 

Thanks Kennan!

0 Likes
Message 22 of 23

Kennan.Chen
Advocate
Advocate

That sounds weird. Can you share some detail about your func1 and func2? 

0 Likes
Message 23 of 23

ariWZRFQ
Enthusiast
Enthusiast

Thanks Kennan,

 

I just sent you an email so that I don't drag this thread much longer. Appreciate the help, let me know if you didn't receive it.

 

Appreciate everyones help and I will update this thread with the resolution.

0 Likes