Page 1 of 1

Closing panel - How to allow threads to complete instead of interrupting them

Posted: Wed Sep 04, 2019 6:54 am
by slamkwon
Hi all,

I'm wondering:

Once a panel is opened and a script is run
if there is a way to allow threads to be completed once clicking the red close button on the title bar.

Currently, when closing a page the event 'terminate' is triggered and all threads are interrupted.
Is there a function that triggers a wait for the threads to complete? (ie. waitThread(Thread1 ID), waitThread(Thread2 ID), )

The current solution I know is to turn off title bars and making a separate close button that forces the threads to close manually, but this doesn't work if the panel is force closed with a CTRL-F4 (same as pressing the X on the title bar).

Could someone help me with this?

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Thu Sep 05, 2019 7:57 am
by buec
Try the panel 'close' event.
On the end of the close script, you have to close the panel with PanelOff( ).

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Thu Sep 05, 2019 8:40 am
by leoknipp
If you have threads which should be finished independent of a user interface or a specific panel you should think about executing these actions in a CTRL manager on the server.
The UI will just send the command to the CTRL manager which then executes the script.

The same solution is used in many functionalities in WinCC OA.

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Tue Sep 10, 2019 2:13 am
by slamkwon
buec wrote: Thu Sep 05, 2019 7:57 am Try the panel 'close' event.
On the end of the close script, you have to close the panel with PanelOff( ).
In the example of dpConnect() this works fine, however when closing an Embedded Module the Close event doesn't work.
Do you know a work around for this?

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Tue Sep 10, 2019 8:54 am
by leoknipp
The "Close" event is part of the panel and not of a module.
The module is just the container for a panel.

What is meant with "closing an embedded module"?

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Wed Sep 11, 2019 3:04 am
by slamkwon
Hi Leopold, I should have been clearer.

When closing a panel within an Embedded Module, the close event isn't triggered. This was verified using DebugN; no event occurs in the log viewer during the close.
However, when closing a panel NOT embedded, the close event works fine and the results are visible in the log.

Hope this clarifies.

Re: Closing panel - How to allow threads to complete instead of interrupting them

Posted: Wed Sep 25, 2019 4:52 pm
by leoknipp
It looks like the "Close" event is only executed if the container (module or childpanel window) where the panel was opened is also closed.
When only switching the panel, e.g. in an Embedded Module, the panel is not closed in the same way and therefore the script is not executed.

Best Regards
Leopold Knipp
Senior Support Specialist