Closed cloudrac3r closed 2 years ago
You can do this by wrapping the window in a mixin and augmenting its on-close
method:
#lang racket/base
(require racket/class
(prefix-in gui: racket/gui)
racket/gui/easy)
(define timer
(new gui:timer%
[interval 5000]
[notify-callback (λ () (displayln "timer called"))]))
(render
(window
#:mixin (λ (%)
(class %
(super-new)
(define/augment (on-close)
(send timer stop))))
(text "Hello")))
Fantastic, works perfectly!
My program runs a timer in the background to periodically refresh the information displayed in the GUI. When the window is closed, the timer remains running and the process keeps running, invisibly.
Is it possible to detect when the main window closes, so that I can stop the timer and end the process?
As always, thank you so much for everything you've done for the Racket world!