11-02-2022 11:55 AM
I create a panel on startup in its own thread then if the user clicks a button, I create another thread using the same function as before(pulls up a duplicate panel). This all works fine until the 14th press of the button. Pressing the button is basically a refresh but it closes the panel and then reopens it. It seems like it will not create another thread. Is there some way to delete the thread when I refresh? I am using DIscardPanel() when closing.
11-03-2022 03:14 AM - edited 11-03-2022 03:15 AM
It is always a good policy to dispose of resources when you do not need them anymore, including threads. Discarding the panel releases the memory associated with it but it does anything to the thread that created the panel.
The minimum you must do to properly terminate a thread is to:
But remember that simpler is better: you may want to reconsider your framework in order to discriminate whether your close-thread-and-create-a-new-one is the best approach to your situation.