在vb.net中运行某些代码时更新控件(进度条,标签等)

时间:2019-03-31 01:07:37

标签: vb.net progress-bar

我正在使用第三方程序COM接口来运行某些模型。同时,tCOM接口让我有机会选择模型仍在运行,并且使用以下代码显示进度/完成百分比是什么。

但是我的主要问题是winform控件不会自我更新。

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

功能正常运行,但是正如我所说,我无法更新下面的代码部分元素。

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

0 个答案:

没有答案