If we run one Wolfram Kernel (Wolfram Engine) there is one thread we can use
While[True,
doSmth;
Pause[0.1];
];
since there is a sort of interruption mechanism ScheduledTask
SessionSubmit[ScheduledTask[Print["Hello!"], {10}]];
While[True,
doSmth;
Pause[0.1];
];
so it can interrupt the main loop in 10 seconds after the start, no matter what happens inside doSmth
. My question is: can we go further and control the loop using ScheduledTask
or SocketListener
?
How can we Abort
something running inside While
?
For example the master
kernel sends the command to abort the running program inside the secondary kernel
(*some master kernel*)
WriteString[kernelsocket, "Abort[]"]
(*some secondary kernel*)
SocketListener[message_] := ToExpression[message];
try catch
construction like to control the evaluation. $\endgroup$