Hi Pavel

Not sure if this will help in your situation but you can try using "primaryStage.setOnCloseRequest" where you can run any cleanup code needed.

If you want to cancel the close request completely then just consume the WindowEvent and then later issue Platform.exit() when ready.

Regards
Jurgen


On Thu, 25 Jul 2024 17:43:25 +0200, PavelTurk <pavelturk2...@gmail.com> wrote:

Hello all.

JavaFX adds its own shutdown hook. That gives many problems when it is necessary to work with application, when system is shutting down, for example, if user presses CTRL+C. The first problem I described here -
https://bugs.openjdk.org/browse/JDK-8320923

Another problem is that after pressing CTRL+C JavaFX seems not to respond anymore. For example I've observed that if after that we try to do Platform.runLater(() -> myCode is here), then myCode will never execute. So, it is necessary to check in system, how it is shutting down, if it is. And this problem creates other problems.

Before opening a feature request, I decided to ask JavaFX developers, if it possible to disable JavaFX shutdown hook. I mean, if there is no system property (something like javafx.shutdownhook.disabled), it will be added, but if I want to call Platform.exit() manually I want to be able to disable JavaFX shutdown hook.

Best regards, Pavel

Reply via email to