Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Windows Dragon

Background Worker

Recommended Posts

Windows Dragon

Boas! Estou com algumas dificuldades a meter o meu background worker a sincronizar com a progressbar alguma ideia? o codigo que tenho e este

Este apenas para iniciar o background worker

 bgWorker.WorkerReportsProgress = True
                bgWorker.WorkerSupportsCancellation = False
                bgWorker.RunWorkerAsync()
                bgProgress.Visible = True

E estes são os outros codigos... do background worker

Private Sub bgWorker_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgWorker.ProgressChanged
        bgProgress.Value = e.ProgressPercentage
    End Sub

    Private Sub bgWorker_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgWorker.RunWorkerCompleted
        bgProgress.Visible = False
        Try
            Process.Start(Application.StartupPath & "\TeknoGods_MW2SP.exe")
        Catch ex As Exception
            MessageBox.Show("ERROR: TeknoGods_MW2SP.exe not found! Make sure that the app is in the game dir!", "ERROR: TeknoGods_MW2SP.exe not found", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End Try
    End Sub


    Private Sub bgWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgWorker.DoWork
        Dim worker As BackgroundWorker = _
        CType(sender, BackgroundWorker)
        File.WriteAllBytes(Application.StartupPath & "\TeknoGods_MW2SP.exe", My.Resources.TeknoGods_MW2SP)
        File.WriteAllBytes(Application.StartupPath & "\TeknoMW2.dll", My.Resources.TeknoMW2)
    End Sub

Mas ele não sincroniza com a progress bar... alguma ideia?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.