Write variable from socket

I want to remotely write global variables. I manage to do it by sending the following code through Primary Interface, but it pauses the running program :

def func():
     global var1=0
end

So I tried with a “sec” program, but it has no effect on global variable :

sec func():
     global var1=0
end

How to write a variable without affecting the main program ? If not possible, is there a way to resume the main program ? (I did not find this feature in the Dashboard server protocol)