Detect Selected Object Bug in Script

Hello fellow grasshoppernians,

I just made a research on developing a c# component that retriggers everytime an objects is selected on rhino. Most of the code is based of a file that David Rutten shared in an old thread (Run Grasshopper Definition on Object Select? - Grasshopper), and that file actually works fine, but the one that I eddited to fill my needs, seem to trigger multiples times exponentially (depending on how many times the component has ran). Here is an example of what I mean:

Anyways, I’m not very familiar with events and would love to understand where did I do wrong in the code. This so I can grow as a developer. Here is the file I edited, if someone wants to take a look. One can reference the bug by the amount of times a line is printed in the rhino command line for just 1 selection.

DetectSelectedObjects.gh (2.6 KB)

Is there any reading material that I’m missing?