How can I create event like behavior when working with MATLAB Builder NE .NET Assemblies?

2 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 6 Dec 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.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!