I have a process that could go on for a long time and sometimes I need to stop it in a much more elegant way than the Ctl-Alt-Del method that I have been using. I know it has to do with running multiple threads using guards, monitors, etc but I'm not sure how to get started. Here is the single thread version of what I am trying to do
Code: Select all
class facts
terminate:() determ.
predicates
onPerform : window::menuItemListener.
clauses
onPerform(Source, _MenuTag):-
/*
Clear the terminate flag*/
retractall (terminate()),
/*
Display the stop dialog modelessly*/
stop::display(Source)=_,
/*
Go into an endless loop and abort the process when the Stop button on the stop dialog box is clicked*/
foreach std::repeat(), not (terminate()) do
stdio::write("performing\n")
end foreach.
set_terminate():-assertz(terminate()).
Code: Select all
predicates
onStopClick : button::clickResponder.
clauses
onStopClick(_Source) = button::defaultAction:-
taskwindow::set_terminate().