Refreshing a canvas.

I have an File Open event handler that reads in a text file and updates the Desktop Applications GUI.
I’m not sure but maybe that violates some threading rules…

What I’m trying to achieve is a to refresh my canvases from a timer event.
I place the timer event on my main window and from the event I call refresh.

If in the loop of the event handler I don’t put app.DoEvents it seems I never get the timer event.
In the end I’d like to be able to ‘tail -f’ this file and keep that a ‘thread’ populating the GUI from the timer.

Any thoughts on what I’m doing wrong?

just use INVALIDATE and let Xojo decide

Is it an infinite loop that depends on the timer to stop it? If so, the loop could be locking the main thread preventing the timer from activating. You may need to adjust your design pattern.

Since you are running a shell command and want to update the UI as the shell outputs data from tail, you might be better off subclassing Shell and setting its mode to 1 (Asynchronous).

That way you can let the shell run in the background and utilize its DataAvailable event to populate your UI.

Still every time I add a point to my graph I don’t want to have to refresh the entire canvas.
Once every 100th update might be good enough…
So do I just call invalidate occasionally?

So App.DoEvent(some magic number)

What is this magic number? Is there a best practice for its use?

Are you actually using a Thread object?

None what so ever.
Just the async shell And a timer.
working pretty well…

TImer seems to be working ok too.

Course I can not redraw my entire graph every time I add a point that takes too long.
So I’m was trying to call Refresh/Invalidate after every 100th add.

Don’t use Refresh. Use Invalidate instead. This will be smoother.

Refresh can be source of flicker.