Main Content

Calling .NET Methods Asynchronously

HowMATLABHandles Asynchronous Method Calls in .NET

It is possible to call a synchronous method asynchronously in MATLAB®. With some modifications, you can use the Microsoft®BeginInvokeandEndInvokemethods. For more information, refer to the MSDN®articleCalling Synchronous Methods Asynchronously.

You can use delegates to call a synchronous method asynchronously by using theBeginInvokeandEndInvokemethods. If the thread that initiates the asynchronous call does not need to be the thread that processes the results, you can execute a callback method when the call completes.

Note

MATLAB is a single-threaded application. Therefore, handling asynchronous calls in the MATLAB environment might result in deadlocks.

UsingEndInvokeWithoutandrefType Arguments

The MATLAB delegate signature forEndInvokefollows special mapping rules if your delegate hasoutorref类型参数。信息的映射,see.NET Delegates With out and ref Type Arguments. For examples, see theEndInvokereference page.

Using Polling to Detect When Asynchronous Call Finishes

For MATLAB to process the event that executes the delegate callback on the main thread, call the MATLABpause(or a similar) function.

See Also

|

External Websites