Link to home
Start Free TrialLog in
Avatar of pvg1975
pvg1975Flag for Argentina

asked on

vb.net multithreading

Hi All!

I have to run a very time consumming process and I thought about putting that piece of code inside a backgroundworker. Is this the right way to do multithreading?

Also, how do I make the code inside the backgroundworker run?

Thanks
Avatar of Darrell Porter
Darrell Porter
Flag of United States of America image

If the process is a linear process, there really is no way to multi-thread the process.
If the process has multiple tasks which can be run in parallel, each of these processes should be set as a backgroundworker thread.

A decent example of using BackgroundWorker can be found at
http://msdn.microsoft.com/en-us/library/8xs8549b.aspx
http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx#Y126
Avatar of pvg1975

ASKER

I saw those examples, but when I try to call the code as:

backgroundworker1.dowork()

I get the following error:

Public Event DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

I just need to know how to call and run the code inside backgroundworker1

Thanks
SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pvg1975

ASKER

Thank you all for the answers :)))
Not even an assist?
Avatar of pvg1975

ASKER

I know I screwed it up after I assigned the points :(

Im sorry about that Stick, I clicked on the email and toke me straight to yv989c answer.

Will press more attention next time.
You can always select to "Request Attention" and have the split performed by a moderator.
Avatar of pvg1975

ASKER

Done :)
Oh, I just answered to your question based on your error, but strickdd gave a detailed information about how to work with the BackgroundWorker class, answering that too, and he pressed the submit button before me ;)