I have a vb.net application (2.0) that has a method that performs two main processes:

1. Perform some complex computation and write data in the form of files to a folder on disk.

2. Copy the files created to a destination folder.

I noticed that Process #2 sometimes started before #1 ended resulting in incomplete files being copied. I verfied the file sizes and found them to be different. Basically, I would like to start Process #2 only on completion of #1.

I used a Thread.Join() and found it to be significantly slower (throughput decreased from 10 seconds to over 2 minutes). What would be the best and the fastest way to do this

Thanks in advance

Re: Visual Basic Language Synchronous processing -- fastest way?


First of all, I would suggest using a background worker if you need any interaction between your background processing and your UI. The BW takes care of the proper invokes and as long as you don't reference any UI members in the DoWork method you will be in good shape.

Second of all, if the task at hand that is running in this background thread is to first write some files, and then copy them I have to wonder why you can't

1) Do both these operations in one background process, doing one after another. This would prevent one from starting before the other finished.


2) If you simply copy the files once they are created to another folder, why not just write them to that destination folder in the first place Unless you need them in more than one spot