The reason why script freeze when I use gh.RunSolver

Hi!
I am trying to write script which can automate to change parameter in slider and export image file.
When I run the following script, it stop to work.
I guess it could go into infinite loop, but don’t know how to confirm and fix it.
Can anyone tell me what is problem and how I can solve?

import rhinoscriptsyntax as rs
import Rhino
import System

gh = Rhino.RhinoApp.GetPlugInObject(“Grasshopper”)

rs.EnableRedraw(True)
#get parameter from slider
for i in range(1,2,1):
gh.SetSliderValue(“2fc274ad-b223-4412-9dfa-583846b25f69”,i)
gh.SetSliderValue(“8e52eafc-2b3d-49ac-9980-8f3776042ca6”,i)
for j in range(1,2,1):
gh.SetSliderValue(“bf6c1195-a839-460c-b891-b41b1befb20c”,j)
gh.SetSliderValue(“6d0830a4-fe91-4b1f-9e95-e2e784fe480a”,j)
for k in range(8,10,1):
gh.SetSliderValue(“62ae003c-1fa8-4254-bdde-7a2e1ad9a0c7”,k)
gh.SetSliderValue(“1136a5e9-202b-43e5-8c19-d1f117a924c7”,k+1)

#If I use gh.RunSolver, script freeze
gh.RunSolver(“160816Light shelf_grid_automate.gh”)

#Save image file
strNum = str(i)+str(j)+str(k)
doc=Rhino.RhinoDoc.ActiveDoc
view=doc.Views.Find(‘Pers’,False)
doc.Views.ActiveView=view
width = view.ActiveViewport.Bounds.Width
height = view.ActiveViewport.Bounds.Height
bitmap = view.CaptureToBitmap(System.Drawing.Size(width, height))
image=System.Drawing.Bitmap(bitmap)

image.Save(strNum+".jpg")