C
ctbfalcon
So I have a progress bar that I would like to be diplayed as the
program is working on adding a network printer. I want to do this
because while the program is "thinking" the user is not sure if it is
locked up or actually doing somthing. So I wanted to start another
thread (form3) with the progress bar on top of the main form (form1).
So I have this. This is the button the kicks off the add printer
function. which also starts the second thread.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
'button is to add/create the selected printer to windows.
Dim t As Thread
t = New Thread(AddressOf Progressbar.Show)
t.Start()
Button2.Enabled = False
Dim WshNetwork As Object = CreateObject("WScript.Network")
Dim PrinterQueueNameSelection As String =
GetcboComboBoxSelectedItem() 'GetComboBox1SelectedItem()
Dim pp As String = GetPrinterPath()
If Not GetifPrinterExsists(pp) Then
If PrinterQueueNameSelection <> "" Then
Try
WshNetwork.AddWindowsPrinterConnection(pp)
MsgBox("Successfully installed printer: " & pp)
Catch Exc As Exception
MsgBox(GetErrorText(3))
End Try
Else
MsgBox(GetErrorText(4))
End If
Else
MsgBox(GetErrorText(9))
End If
t.Abort()
Button2.Enabled = True
End Sub
I dont care how long the progress bar is run so I abort it once the add
printer function is done successfully or not.
If I run the Progressbar.show in the same thread by itself it works
fine, just the way i want it too.
And of course if i run the progressbar.show in the same thread along
with the add printer it does not start until the printer function is
done. Then continues to display the bar.
If I put the progressbar.show in a separate thread along with the add
printer function is "blinks" up, does not display anything. This is
were i would expect it to show itself continue to display the bar as
the main thread adds the printer.
I hope i explained this ok, if you need anymore code let me know.
Thanks for any help in advance.
program is working on adding a network printer. I want to do this
because while the program is "thinking" the user is not sure if it is
locked up or actually doing somthing. So I wanted to start another
thread (form3) with the progress bar on top of the main form (form1).
So I have this. This is the button the kicks off the add printer
function. which also starts the second thread.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
'button is to add/create the selected printer to windows.
Dim t As Thread
t = New Thread(AddressOf Progressbar.Show)
t.Start()
Button2.Enabled = False
Dim WshNetwork As Object = CreateObject("WScript.Network")
Dim PrinterQueueNameSelection As String =
GetcboComboBoxSelectedItem() 'GetComboBox1SelectedItem()
Dim pp As String = GetPrinterPath()
If Not GetifPrinterExsists(pp) Then
If PrinterQueueNameSelection <> "" Then
Try
WshNetwork.AddWindowsPrinterConnection(pp)
MsgBox("Successfully installed printer: " & pp)
Catch Exc As Exception
MsgBox(GetErrorText(3))
End Try
Else
MsgBox(GetErrorText(4))
End If
Else
MsgBox(GetErrorText(9))
End If
t.Abort()
Button2.Enabled = True
End Sub
I dont care how long the progress bar is run so I abort it once the add
printer function is done successfully or not.
If I run the Progressbar.show in the same thread by itself it works
fine, just the way i want it too.
And of course if i run the progressbar.show in the same thread along
with the add printer it does not start until the printer function is
done. Then continues to display the bar.
If I put the progressbar.show in a separate thread along with the add
printer function is "blinks" up, does not display anything. This is
were i would expect it to show itself continue to display the bar as
the main thread adds the printer.
I hope i explained this ok, if you need anymore code let me know.
Thanks for any help in advance.