Anyway, it does not work without Application.QueueAsyncCall(@PlotMethod,0);, but with it it is fine.
As the name suggests, this will add the @
{Self.}PlotMethod to the internal queue for execution. When the Application is into it's main GUI thread it will fetch from that queue and execute it asynchronously. The key phrase here is: "the main GUI thread". All of the GUI processing must be done in that thread!
Is it wrong to call it inside PlotMethod? It seems to work fine this way:
Calling Application.RemoveAsyncCalls(
Self) will remove from the internal queue all previously added (but yet not realized) calls.They must be removed before destroying the object (ie. the red Self above) because otherwise they'll be invoked on a
dangling pointer. See the first red {Self.} in QueueAsyncCall, which is implicit, but it's there!
So, I don't know if it is wrong to call it into PlotMethod (depends on the use case) but it's wrong not to call it just before destroying the PlotMethod's object instance.