944,131 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3443
  • VB.NET RSS
Sep 4th, 2007
0

Threaded Backup Utility

Expand Post »
I have a backup utility that copies all files and folder into a backup area

This can take some time as the files take up 92Mb over a 1Mbps Data Link


I have added multi-threading to the utility so that the copy can be aborted and so the GUI keeps active.
but i would like to add a progress bar based on the current number of files copied.

The only problem is that the only area that can access the progress bar is the Main Thread which is not the Thread doing the file copies.



Is there any way to put the Progress bar in the copying thread, Access the forms control from another thread or create a new form control that is on the Form but generated by the Copying Thread?
Similar Threads
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Sep 5th, 2007
0

Re: Threaded Backup Utility

Quote ...
Is there any way to put the Progress bar in the copying thread, Access the forms control from another thread or create a new form control that is on the Form but generated by the Copying Thread?
Yes, there is! What you need to do is access the controls through a dummy interface that calls Invoke on the control instead of manipulating it directly if it's not on the main thread.
vbnet Syntax (Toggle Plain Text)
  1. Delegate Sub SetProgressPropertyCallback( ByVal property As String, ByVal value As Integer )
  2.  
  3. Private Sub SetProgressProperty( ByVal property As String, ByVal value As integer )
  4. If ProgressBar1.InvokeRequired Then
  5. Dim d As New SetProgressPropertyCallback( AddressOf SetProgressProperty )
  6.  
  7. Me.Invoke( d, New Object() { property, value } )
  8. Else
  9. Select Case property
  10. Case "Value"
  11. ProgressBar1.Value = value
  12. Case "Max"
  13. ProgressBar1.Maximum = value
  14. Case "Min"
  15. ProgressBar1.Minimum = value
  16. End Select
  17. End If
  18. End Sub
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 5th, 2007
0

Re: Threaded Backup Utility

Hamrick

Thanks Hamrick,
It worked perfectly
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Many-to-one relationships
Next Thread in VB.NET Forum Timeline: Database not found error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC