Threaded Backup Utility

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Threaded Backup Utility

 
0
  #1
Sep 4th, 2007
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?
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: Threaded Backup Utility

 
0
  #2
Sep 5th, 2007
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.
  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
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Threaded Backup Utility

 
0
  #3
Sep 5th, 2007
Hamrick

Thanks Hamrick,
It worked perfectly
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC