0

您好,我正在尝试在我的程序中制作一个实时记录器,以便跟踪进度。像这样:

http://i.stack.imgur.com/cmcTp.png

我怎么做这样的东西。

4

1 回答 1

0

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

您可以使用带有列表框的后台工作人员来完成您的要求。在后台工作人员的报告进度方法上,您可以指定“用户状态”对象“记录”到 UI 线程上的控件,只需确保将“工作人员报告进度”设置为 true:

 Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'where you call your worker to do work
    BackgroundWorker1.RunWorkerAsync()


End Sub


Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    'make sure to set worker reports progress to true
    BackgroundWorker1.ReportProgress(0, "About to Messagebox") 'where 0 is a progress percent if you want it and the string is overloaded
    MsgBox("This is to show how to report before an event!")


End Sub

Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged

    '
    ListBox1.Items.Add(e.UserState)


End Sub
End Class
于 2013-09-06T17:51:10.480 回答