ExternalEvent.Raise() should accept parameters

ExternalEvent.Raise() should accept parameters

Anonymous
Not applicable
5,355 Views
24 Replies
Message 1 of 25

ExternalEvent.Raise() should accept parameters

Anonymous
Not applicable

I know this can be achieved in other ways, but i want to discuss the fact that this would be much understandable for developers ...

 

would be nice to have generics involved here having an interface like this:

 

IExternalEventHandler<T>


ExternalEvent<T> EE =  ExternalEvent.Create(handler IExternalEventHandler<T>);
EE.Raise(T obj);

 

0 Likes
Accepted solutions (1)
5,356 Views
24 Replies
Replies (24)
Message 21 of 25

jeremytammik
Autodesk
Autodesk

If you have an issue with the execution sequence, how about adding a millisecond-precise timestamp to each request before sending it, and sorting the requests by timestamp before executing them?

 



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

0 Likes
Message 22 of 25

Anonymous
Not applicable

Jeremy, the problem is not in the execution sequence. Events are getting executed in the right order. The problem is that since the external event doesn't take an argument, I need to make sure that I am only raising one event at a time after setting the correct arguments in the event handler. The isPending property of event is set to false as soon as the event execution starts but before it finishes, and hence I can not rely on that to raise the next event. What Joshua suggested will work though.

0 Likes
Message 23 of 25

nice3point
Advocate
Advocate

@Anonymousyou can use these external events, including asynchronous events with return value https://github.com/Nice3point/RevitToolkit#external-events

0 Likes
Message 24 of 25

matveevri
Explorer
Explorer

This is prefect, i was looking for this solution for year or more and all this time it was here. By this handler i can pass any argument to execute command.

0 Likes
Message 25 of 25

Kennan.Chen
Advocate
Advocate

Actually, the Revit.Async library is designed specifically to address this issue. Additionally, it provides the functionality to return results to the event caller. This allows you to use external event just like calling an asynchronous function.

 

Take a look at it here

0 Likes