Backgroundworker进度栏选框虽然很忙?

时间:2014-01-03 05:32:31

标签: vb.net

所以我很确定它很简单但我试图启动marqee进度条样式,运行一个函数,而不是在完成时停止它。

我有背景工作者;

make_progress(改进进度) make_complete(工人完成) make_dowork(我调用函数的地方) makebuttonm(按钮点击发件人到make_dowork) makefunction(我的代码的核心)

我已经尝试将make_progress.reportprogress(x)放入函数中,也尝试调用样式来更改按钮(在调用do_work进程之前)并且没有一个启动选取框但是UI是免费的,并且我看到创建的文件..

困难的部分是我没有办法看到“进展”因为即时通讯等待外部命令完成...并且使用consoleredirect最终只是冻结我的UI

有关何处致电开始的任何建议? (工作完成后很容易结束)我在正确的地方有我的处理程序

Function MakeAppx()
    On Error Resume Next

    Dim ProgDir As String = "C:\"
    Dim listofapp As List(Of String) = FileHelper.GetFilesRecursive(ProgDir)
    Dim FoundApp As New List(Of String)
    Dim AppPath As String
    PackappComplete = False

    'Find Each Instance of the makeappx.exe file, gets absolute path for us
    For Each I In listofapp
        If I.Contains("x) Then
            AppPath = I
            make.StartInfo.FileName = (AppPath)
            Exit For
        End If
    Next

    Dim Per As Integer
    Per = Per + 1

    make.StartInfo.Arguments = psi
    make.StartInfo.RedirectStandardOutput = True
    make.StartInfo.UseShellExecute = False
    make.StartInfo.CreateNoWindow = True
    make.Start()

End Function
Private Sub bw_make(ByVal Sender As Object, e As EventArgs) Handles packapp.DoWork
    packapp.WorkerReportsProgress = True
    AddHandler packapp.ProgressChanged, AddressOf packapp_change
    AddHandler packapp.RunWorkerCompleted, AddressOf packapp_complete
    Sender = MakeAppx()

End Sub
Private Sub packapp_change(ByVal sender As Object, ByVal e As ProgressChangedEventArgs) Handles packapp.ProgressChanged
    copyprogress.Style = ProgressBarStyle.Marquee
End Sub
Private Sub packapp_complete(ByVal sender As Object, ByVal e As EventArgs) Handles bw.RunWorkerCompleted



End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    AddHandler packapp.ProgressChanged, AddressOf packapp_change
    AddHandler packapp.RunWorkerCompleted, AddressOf packapp_complete
    OrigionalAppLoc = My.Computer.FileSystem.GetDirectories(LocalApps).ToList

    copyprogress.Style = ProgressBarStyle.Marquee

    For Each I In OrigionalAppLoc
        If I.Contains(Trim(lbGetApps.SelectedItem)) Then
            apppath = I
        End If
    Next
    psi = (" pack /l /d """ & Trim(apppath) & """ /p ""C:\Apps\" & Trim(lbGetApps.SelectedItem) & ".appx""")
    packapp.RunWorkerAsync(sender)

End Sub

0 个答案:

没有答案