?
Solved

Update Modal Dialog Progress Bar using Background Worker in VB.Net

Posted on 2012-03-21
2
Medium Priority
?
2,566 Views
Last Modified: 2012-03-21
I promise I've looked for hours on a clear and concise VB.Net version of doing this. I can only piece together little bits and not the whole picture.

I have a parent form and a dialog pop up. I want to pop the dialog window, which contains a progress bar, and update the progress bar from the parent form as specific tasks are completed on the parent form.  That's it. I found an example that Idle_mind gave here, but it's c#, and it's not communicating to the modal dialog.

Help?

-MJC
0
Comment
Question by:Rainverse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 37748669
Here's one way...by passing a reference to the BackgroundWorker() into the Progress Form:
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False
        Dim progress As New frmProgress(Me.BackgroundWorker1)
        progress.ShowDialog()
        Button1.Enabled = True
        MessageBox.Show("Done!")
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        For i As Integer = 1 To 100
            System.Threading.Thread.Sleep(100)
            BackgroundWorker1.ReportProgress(i)
        Next
    End Sub

End Class

Open in new window


Public Class frmProgress

    Private WithEvents _BGW As System.ComponentModel.BackgroundWorker

    Public Sub New(ByVal BGW As System.ComponentModel.BackgroundWorker)
        _BGW = BGW
        InitializeComponent()
    End Sub

    Private Sub frmProgress_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
        If Not IsNothing(_BGW) Then
            _BGW.RunWorkerAsync()
        End If
    End Sub

    Private Sub _BGW_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles _BGW.ProgressChanged
        ProgressBar1.Value = e.ProgressPercentage
    End Sub

    Private Sub _BGW_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles _BGW.RunWorkerCompleted
        Me.Close()
    End Sub

End Class

Open in new window

0
 
LVL 5

Author Closing Comment

by:Rainverse
ID: 37748850
I was hoping you'd answer. Works great! Thanks!

-MJC
0

Featured Post

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question