DynamoDS / Dynamo

Open Source Graphical Programming for Design
https://dynamobim.org
Other
1.68k stars 622 forks source link

start using new 2013 External Events framework to handle modeless interaction wiht Dynamo #20

Closed tatlin closed 9 years ago

tatlin commented 11 years ago

External Events framework The External Events framework is a new API framework tailored for asynchronous processing such as that which is needed to support modeless dialogs. It operates similarly to the Idling event with default frequency. With this framework, instead of implementing an event handler and implementing the handler to do nothing when there is no activity in your dialog, instead you do the following:

  1. Implement an external event by deriving from the interface: • IExternalEvent
  2. Create an ExternalEvent with • ExternalEvent.Create()
  3. When an event happens in your modeless UI where a Revit action needs to be taken, call • ExternalEvent.Raise()
  4. Revit will wait for an available Idling timecycle and call the implementation of your event: • IExternalEvent.Execute() This framework is more useful for modeless dialog developers because you can skip the default no-op implementation when nothing has happened, and tell Revit when there is some work you need to do in Revit. It also saves on the time required for Revit to make repeated calls to the Idling event when there is no actual work to be done.
Steell commented 11 years ago

Most of this is accomplished using the IdlePromise class, which does the same thing that the External Events framework does (from my understanding.) We should definitely change to External Events once we are certain that we can maintain the same amount of control over the execution that is given to us via IdlePromise.