For that to work in c# you will need to have things outside of the solve instance and you could use a timer potentially or a delay.
Whatever you do in the solve instance will only output the final result (in your case, false).
In Python you could use things like callback Simulate a button click with python