2 Replies Latest reply on Dec 19, 2013 2:11 AM by Oleg Bezyaev

    Subscribe to event

    Oleg Bezyaev

      How to check whether the code is subscribe to some solidworks event?

      For example, I want to know the addon was subscribed to event DPartDocEvents_NewSelectionNotifyEventHandler, if not - then subscribe if yes - continue the program.

        • Re: Subscribe to event
          Artem Taturevych

          Do you want to check that you have already subscribed to avoid multiple handling of the same event? If so I would simply suggest to unsubscribe of the event before subscribing:

           

          … -= DPartDocEvents_NewSelectionNotifyEventHandler (…)

          … += DPartDocEvents_NewSelectionNotifyEventHandler (…)

           

          If the event is not subscribed it will just skip this otherwise will unsubscribe and subscribe again so you can be sure that it is always only one handler.