0

I'm using a third part program COM interface to run my some models. At the same time tCOM-interface gives me an oppurtunity to chec is model still running and what is it's progress/complete percentage with below codes.

But my main problem is winform controls doesn't updating themselves.

Private Sub NewMethod()
        Dim obj As IScrBackgroundSolverResult

        'This is COM interface procedure runs my model at the 3rd part program
        ‘Runs some code in background   
        obj = integBG("D:\Test\sample_model.mnf")

        ' Returns True if it's running otherwise False - This information comes from 3rd part's com interface isRunning() function
        obj.isRunning()

        ' Returns True if it's running otherwise False - This information comes from 3rd part's com interface getProgress() function
        ' It's start from 0 to 100
        obj.getProgress()

        While obj.isRunning = True
            ProgressBar1.Value = obj.getProgress
            Label1.Text = "Running"
        End While
    End Sub

Functions are working properly but as i said i couldn't update my below code section elements.

   While obj.isRunning = True
        ProgressBar1.Value = obj.getProgress
        Label1.Text = "Running"
    End While
Jam
  • 1
  • What you have there is called a "busy wait" and it is probably the worst construct in all of programming. That loop is going to push your CPU to run at 100% and, as long as the loop is running, the UI thread is not free to actually update the graphical representation of those controls. NEVER use a busy wait. Time to do some research on alternatives. – jmcilhinney Mar 31 '19 at 01:15
  • So if you put a timer there and put the progressbar inside to get a value from obj.getProgress() does it get a percentage progress number or not? – OctaCode Mar 31 '19 at 12:47

0 Answers0