Hello @eirannejad
about:
I think the example of bone manipulation is the most illustrative.
Here, several elements that require a subscription are necessary to make this demo work:
MouseCallback class, DisplayConduit class, Command.BeginCommand event, and Command.EndCommand event
MouseCallback
Allows capturing mouse inputs to move the blue circles.
To avoid capturing mouse inputs as many times as there have been compilations, the MouseCallback must be deactivated before recompilation and then activated after the new DLL file is generated.
To draw a parallel between the code present in the video below and ScriptEditor, we can consider that the code is in Script Mode (I actually use the CSX syntax) and I connect the inputs, outputs, and callback functions with attributes [Input], [Output], [OnContext], and [OnUnload].
The OnContext function is called by GH_Component.DocumentContextChanged(GH_Document document, GH_DocumentContext context) and receives the parameter GH_DocumentContext context, which allows managing all the Load/Unload, Open/Close, Lock/Unlock scenarios.
The OnUnload function, on the other hand, is called before all instances of objects created by the script are cleaned up and a new DLL file is generated and loaded into the component. (Since static variables are created only once, I did not need to implement an OnLoad function).
These two functions are called only once for each component, regardless of the number of parameters and their accessibility.
It should be noted that it would be useful to add the GotFocus and LostFocus scenarios to the OnContext function in case the Rhino window take or loses focus. I find this is a missing feature in the Timer component of Grasshopper. If you open your email to reply to a message, the script continues to run, which can be useful in some cases but not in all.
DisplayConduit
Displays the blue points, the purple curve, and the orange outline of the active sphere in the image below:

This object must also be properly deactivated to avoid drawing multiple times per viewport frame.
It would have been possible to use the Grasshopper CustomPreview component. However, the purple curve and the orange outline are displayed only if the mouse is over the sphere, so it is more practical and efficient to use a DisplayConduit directly.
Command.BeginCommand and Command.EndCommand
These two functions allow activating or deactivating the MouseCallback and the DisplayConduit while a Rhino command is executed, for example, Save.
Again, these events must be unsubscribed before each recompilation and re-subscribed with the functions of the newly generated DLL.
I hope I have been clear and precise enough, and I will answer your other questions gradually with other messages.
While searching the forum, I came across this thread which is apparently a revival from 2014 of the old Grasshopper site: