| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB Builder NE |
| Contents | Index |
| Learn more about MATLAB Builder NE |
| On this page… |
|---|
The MATLAB Builder NE 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 M-code are displayed. Typically you use WaitForFiguresToDie when:
There are one or more figures open that were created by a .NET component created by the builder.
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 console.readline method when possible as it accomplishes much of this functionality in a standardized manner. |
Caution Use care when calling the WaitForFiguresToDie method. Calling this method from an interactive program, such as Microsoft Excel, can hang the application. This method should be called only from console-based programs. |
The following example illustrates using WaitForFiguresToDie from a .NET application. The example uses a .NET component created by the MATLAB Builder NE product; the object encapsulates M-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 M-file:
drawplot.m
function drawplot()
plot(1:10);
Use MATLAB Builder NE to create a .NET component with the following properties:
| Component 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.
![]() | Accessing Real or Imaginary Components Within Complex Arrays | Using MATLAB API Functions in a C# Program | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |