The MATLAB® Compiler SDK™ product adds a WaitForFiguresToDie
method
to each .NET class that it creates. WaitForFiguresToDie
takes
no arguments. Your application can call WaitForFiguresToDie
any
time during execution.
The purpose of WaitForFiguresToDie
is to
block execution of a calling program as long as figures created in
encapsulated MATLAB code are displayed. Typically you use WaitForFiguresToDie
when:
There are one or more figures open that were created by a .NET assembly created by the MATLAB Compiler SDK product.
The method that displays the graphics requires user input before continuing.
The method that calls the figures was called from main()
in
a console program.
When WaitForFiguresToDie
is called, execution
of the calling program is blocked if any figures created by the calling
object remain open.
Tip
Consider using the |
Caution
Use care when calling the |
The following example illustrates using WaitForFiguresToDie
from
a .NET application. The example uses a .NET assembly created by the MATLAB Compiler SDK product;
the object encapsulates MATLAB code that draws a simple plot.
Create a work folder for your source code. In this example,
the folder is D:\work\plotdemo
.
In this folder, create the following MATLAB file:
drawplot.m function drawplot() plot(1:10);
Use MATLAB Compiler SDK to create a .NET assembly with the following properties:
Assembly name | Figure |
Class name | Plotter |
Create a .NET program in a file named runplot
with
the following code:
using Figure.Plotter; public class Main { public static void main(String[] args) { try { plotter p = new Plotter(); try { p.showPlot(); p.WaitForFiguresToDie(); } catch (Exception e) { console.writeline(e); } } } }
Compile the application.
When you run the application, the program displays a plot from 1 to 10 in a MATLAB figure window. The application ends when you dismiss the figure.
Note:
To see what happens without the call to |