I'm writing an assembly using the Mako SDK. I'm using the writeAssembly(...)
method of IPDFOutput
, but I don't know how I can cancel writing the assembly, if it's a large, long running file.
I see that I can provide a ProgressCallbackFunc
, but I'm not sure how to signal the write to be cancelled.
How I can interrupt the writing the assembly?
The call to writeAssembly(...)
includes a parameter for a progress call back, as you pointed out. From the callback, you can simply throw an error from there to terminate interrupt and end the writeAssembly(...)
call.
An example of a callback function that terminates when ESC is pressed may look like:
static void progressFunc(void *priv, float progress)
{
wprintf(L"Percentage complete: %3.1f%%\r", progress * 100.0);
if (_kbhit())
{
if (_getch() == 27) // ESC;
throwEDLError(EDL_ERR_ABORTED);
}
}
The writeAssembly(...)
call would then look like this:
output->writeAssembly(assembly, outputFilePath, progressFunc);