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

Find and share HowTos to various installations / configurations!
Search

Post Reply
7 posts • Page 1 of 1
slamkwon
Posts: 19
Joined: Wed Oct 10, 2018 2:20 am

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

Post 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?

buec
Posts: 28
Joined: Tue Dec 07, 2010 3:09 pm

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

Post by buec »

Try the panel 'close' event.
On the end of the close script, you have to close the panel with PanelOff( ).

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

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

Post 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

slamkwon
Posts: 19
Joined: Wed Oct 10, 2018 2:20 am

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

Post 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?

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

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

Post 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

slamkwon
Posts: 19
Joined: Wed Oct 10, 2018 2:20 am

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

Post 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.

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

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

Post 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

Post Reply
7 posts • Page 1 of 1