Ho to detect a new compile of a c# script?

Hi all.

Give a simple class like:

private void RunScript(object x, object y, ref object A)
    obj = new MyClass(this.Component);

  // <Custom additional code> 
  public MyClass obj;

  public class MyClass{
    IGH_Component comp;
    public MyClass(IGH_Component Comp){
      comp = Comp;

That “obj” object can run methods internally autonomously. Load on the CPU.
I can manage that class easily from the main void RunScript.

But if, before stopping that object, I open the script editor, make some edit, and close (triggering a new compile of the c# component) … I’ll lose any connection to that object!
“comp” always return valid, even after re-compile.
My new “obj” object will be a new, different object (after recompile), and now I have no control over the previous one.

How to solve this?
Any suggestions? Workarounds?