How can I create event like behavior when working with MATLAB Builder NE .NET Assemblies?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 6 Déc 2013
Réponse apportée : MathWorks Support Team
le 16 Avr 2014
When calling my MATLAB Builder NE Assembly from a .NET application, I want to be able to provide feedback from the MATLAB side to the .NET side. For example to provide progress feedback when running a long calculation. In .NET you would normally use events for this.
Réponse acceptée
MathWorks Support Team
le 6 Déc 2013
The ability the define actual events for .NET Assemblies is not available in MATLAB Builder NE R2013b, it only supports adding actual events when compiling the MATLAB code into a COM Class.
So as a workaround you can create COM Classes instead of .NET Assemblies; calling COM Classes from .NET is usually just as easy as calling another .NET Assembly. However, as of release R2011a, MATLAB Builder NE supports a new type MWObjectArray which provides an alternative workaround. With MWObjectArray it is possible to pass a .NET object from the .NET side to the MATLAB side. In your MATLAB code you can then call methods on this object. Although this does not allow you to create actual .NET events, you can use this to create event like behavior. The attached example demonstrates this. It even demonstrates how this allows you to do even more than just get event like behavior, it can for example be used to cleanly abort a long running calculation.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!