AdvancedHMI Software
General Category => Support Questions => Topic started by: phuz on May 10, 2020, 11:32:16 AM
-
I couldn't find a relevant thread on this, so if it does exist, my apologies.
I understand that unsubscribing on close is a form of good housekeeping, but is it necessary? If so, must you loop through each unique ID or is there a method to just dispose of all active subscriptions?
I mean, sure it's very simple...just wondering how necessary it is.
While subscriptionID > 0
mainplc.UnSubscribe(subscriptionID)
subscriptionID = subscriptionID - 1
End While
-
If a form is closed with a driver instance on it, all of the subscriptions are terminated automatically. This is because subscriptions live in the driver instance and not in the backend DLL. So closing a form disposes the driver instance, which in turn deletes all subscriptions
-
I assume the same is true if driver is initialized in a service application instead of a form?
-
If you are doing all code, it is up to you to properly handle disposing of driver instances. Otherwise the subscription threads will continue to run.
-
Would it be sufficient to say "EthernetCLXDriver.DisableSubscriptions = True" on form close and call it a day?
-
DisableSubcriptions only pauses the update process. It does not shut down the subscriptions threads
-
Is there a way to get a list of all active subscriptions?
-
I don't think there is a way to expose the list of active subscriptions. It is really up to you to keep a list of the subscription IDs.
If you want to unsubscribe from them all, a hack you can use is to create a new subscription to get the latest ID. The use a loop from 0 to the latest ID to call Unsubscribe on each ID