Thanks for your answer. It appears that this semaphore and additional function should be done for all interface calls... Have you considered fixing this apparent design issue in upp? Why we cannot have upp serialize (if it needs to) the gui calls transparently, so that there would be no limits for threads calling the gui?
Yes, it is planned.
Quote:
Additional question. Suppose we have a kill button in the GUI. void Task::KillButton(). How to kill the thread in this function? We presume the thread is heavy and cannot ping asking the interface for ShouldWeCancelNow() frequently enough to be able to shutdown itself.
I am afraid that killing the thread is not as easy as it might seem - who would free all associated resources?! (e.g. allocated memory, opened files and sockets...).
That is why I think that some form of "ShouldWeCancelNow" is in fact necessarry. It can take the form of periodic call to some function which in case of cancel throws exception - that IMO is the most effective way.