Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
- Nevermind... I'll just handle it myself - Removed.
Posted
Updated 14-Jun-12 4:33am
v3

I think putting the delegate as a parameter in the sub new is a bit much/not needed. The class object knows all of it's parts so just initialize the delegate in the constructor.

VB
Try
   'whatever
Catch ex As Exception
   'if you don't check the exception you won't which object is having a problem.
End Try
 
Share this answer
 
We also have no idea how your using this class. If you calling code is setting up it's own threads, there's no need for it because this class handles all of that for you.

Really, this has got to be the most convoluted file copy code I've ever seen, even for a threaded version.
 
Share this answer
 
A class object is a great way to handle a threaded operation and be able to pass data. The idea is to create the new class object set it's values as needed then the thread calling setting this into action calls a new thread - the class object does not have to worry about async operations as it has it's own thread and when done it cleans itself up all by itself.

VB
Dim obj As New {your class}
obj.Filename = "some file to copy"
Dim thrd As New Thread(AddressOf obj.Worker)
thrd.IsBackground = True 'belongs to this calling process/UI
thrd.Start()
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900