MLWaitForLinkActivityWithCallback (C Function)
MLWaitForLinkActivityWithCallback has been replaced by WSWaitForLinkActivityWithCallback.
int MLWaitForLinkActivityWithCallback(MLINK l, MLLinkWaitCallBackObject callback)
does not return until the MathLink connection specified by l has data to read, but periodically calls back to the function passed as callback.
Details

- Use MLWaitForLinkActivityWithCallback() on a background thread that needs to wait for data in order not to block any user interface or main threads of the application.
- Use MLWaitForLinkActivityWithCallback() (or the related function MLWaitForLinkActivity()) when needing to wait for link activity on a link that is enabled for logging.
- MLWaitForLinkActivityWithCallback() returns MLWAITERROR in the event of an error and MLWAITSUCCESS if the function succeeds.
- MLLinkWaitCallBackObject is a pointer to a function of the form int function(MLINK, void *). The second argument is reserved for future use. If the function returns 1, MLWaitForLinkActivityWithCallback() will return MLWAITCALLBACKABORTED.
- MWaitForLinkActivityWithCallback() is declared in the MathLink header file mathlink.h.
Examples
Basic Examples (1)
#include "mathlink.h"
/* A function for MathLink to call back to while waiting */
int WaitFunction(MLINK l, void *future)
{
/* By default do not back out of
MLWaitForLinkActivityWithCallback(). */
return 0;
}
/* A function for waiting for link activity */
void f(MLINK l)
{
switch(MLWaitForLinkActivityWithCallBack(l, WaitFunction))
{
case MLWAITERROR:
/* Handle the error */
break;
case MLWAITSUCCESS:
/* Now read incoming data */
break;
case MLWAITCALLBACKABORTED:
default:
/* WaitFunction decided to abort the wait. */
}
}