You cannot change slider values within solutions. Because this will expire the slider and all objects that depend on the slider causing a potentially infinite recursion of objects expiring other objects. Or rather, it will recurse until the call stack is full at which point you will crash.
If you want to do something 5 seconds from now, there’s two sensible approaches:
- Use a genuine Timer class and handle the callback. Note that these timers run on threads other than the UI thread, and thus the callback will be invoked on a thread other than the UI thread. This means that before you tell Grasshopper to do anything like start a new solution, you must first make sure that your code is hoisted over to the correct thread. This can be done using the Invoke on any winforms control, or RhinoApp.InvokeOnUiThread.
- Or better yet, use the GH_Document.ScheduleSolution method which does all the above behind the scenes. You provide a callback when you schedule a solution and inside that callback you change the slider values.
Alternatively you can write your code in a class which runs outside of the solution (like Galapagos). This can mean putting it inside a window and have it triggered by button presses or other UI events, or it can mean creating a class instance which gets ‘activated’ once a solution is finished.