Custom Progress Bar Show Dialog

B

B-Dog

I'm trying to build a custom progress bar that will run as some subs are
running in the background but when I open the custom form with the progress
bar on it using the showdialog, none of the subs run until the form is
closed but I need the form to be on top so the users can't click anywhere
else till the tasks are complete. How would I go about doing this? I need
to open this form, runs some subs, then close the form. Thanks
 
H

Herfried K. Wagner [MVP]

* "B-Dog said:
I'm trying to build a custom progress bar that will run as some subs are
running in the background but when I open the custom form with the progress
bar on it using the showdialog, none of the subs run until the form is
closed but I need the form to be on top so the users can't click anywhere
else till the tasks are complete.

Multithreading:

<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>

<URL:http://www.devx.com/dotnet/Article/11358/>

<URL:http://msdn.microsoft.com/library/e...SystemWindowsFormsControlClassInvokeTopic.asp>

Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>

Sample:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
 
B

B-Dog

Hmmn, I didn't know that was considered multithreading. Thanks for the
info, I'll check it out.
 
B

B-Dog

I can't figure out these threads, I've read over this stuff and still don't
understand it. Could anyone help me with this below to try and fire my form
as dialog then run another sub then close dialog when complete. This is what
I started with

Dim f As New Progressx("your data is being exported")

f.ShowDialog()

ExportExcel()

f.Close()



I've tried this but of course I don't know what I'm doing, the form opens
and the process runs but the stuff on the new form doesn't work, I have a
timer on the form I'm opening with the show dialog and it doesn't stay
running



Dim f As New Progressx("your data is being exported")

Sub LaunchNight()

f.ShowDialog()

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bExport.Click

Dim t As Thread = New Thread(AddressOf LaunchNight)

t.Start()

ExportExcel()

f.Close()

End Sub
 
B

B-Dog

Here is the code on the form I'm trying to open while process long sub.
Essentially, I'm trying to have a small form open up that does the night
rider thing while we are waiting.

Dim Forward As Boolean = True

Dim x As Integer = 0

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

If Forward Then

If x > 115 Then Forward = False

x += 1

Else

If x <= -9 Then Forward = True

x -= 1

End If

Me.imgProgress.Left = x

End Sub





B-Dog said:
I can't figure out these threads, I've read over this stuff and still don't
understand it. Could anyone help me with this below to try and fire my form
as dialog then run another sub then close dialog when complete. This is what
I started with

Dim f As New Progressx("your data is being exported")

f.ShowDialog()

ExportExcel()

f.Close()



I've tried this but of course I don't know what I'm doing, the form opens
and the process runs but the stuff on the new form doesn't work, I have a
timer on the form I'm opening with the show dialog and it doesn't stay
running



Dim f As New Progressx("your data is being exported")

Sub LaunchNight()

f.ShowDialog()

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bExport.Click

Dim t As Thread = New Thread(AddressOf LaunchNight)

t.Start()

ExportExcel()

f.Close()

End Sub

<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.a
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.a
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.a
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFo
rmsControlClassInvokeTopic.asp>

Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisu
albasic.asp>
<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEn
 
B

B-Dog

Well I got it working but don't know right, I was running thread on the
wrong form and ran processes on new form and it worked great.

Dim t As Thread = New Thread(AddressOf LaunchSub)

Dim Forward As Boolean = True

Dim x As Integer = 0

Sub LaunchSub()

main.ExportExcel()

Me.Close()

t.Abort()

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

If Forward Then

If x > 115 Then Forward = False

x += 1

Else

If x <= -9 Then Forward = True

x -= 1

End If

Me.imgProgress.Left = x

End Sub

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

t.Start()

End Sub



B-Dog said:
Here is the code on the form I'm trying to open while process long sub.
Essentially, I'm trying to have a small form open up that does the night
rider thing while we are waiting.

Dim Forward As Boolean = True

Dim x As Integer = 0

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

If Forward Then

If x > 115 Then Forward = False

x += 1

Else

If x <= -9 Then Forward = True

x -= 1

End If

Me.imgProgress.Left = x

End Sub





B-Dog said:
I can't figure out these threads, I've read over this stuff and still don't
understand it. Could anyone help me with this below to try and fire my form
as dialog then run another sub then close dialog when complete. This is what
I started with

Dim f As New Progressx("your data is being exported")

f.ShowDialog()

ExportExcel()

f.Close()



I've tried this but of course I don't know what I'm doing, the form opens
and the process runs but the stuff on the new form doesn't work, I have a
timer on the form I'm opening with the show dialog and it doesn't stay
running



Dim f As New Progressx("your data is being exported")

Sub LaunchNight()

f.ShowDialog()

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bExport.Click

Dim t As Thread = New Thread(AddressOf LaunchNight)

t.Start()

ExportExcel()

f.Close()

End Sub
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.a<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.a<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.a<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFo<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisu<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top