Passing values between running threads ? 
Author Message
 Passing values between running threads ?

        Have written a program to read data from a couple hundred Excel
files. (inVB.Net)
        The first time the program is run, this is done in the form load
event. Because this process takes several minutes, the user spend what seems
like forever sitting and staring at a blank screen.
        I decided that I wanted to add another form which would display a
progress bar while this load event was taking place. Spent the past several
weeks trying to beat the concept of threading into my thick skull. Thought I
understood it, but I just don't know how to go about doing what i want to do
for this application. The tutorials and examples that I've found really
don't cover what I want to do.
        I already have the loop written that gets the data from Excel, so I
was hoping that I could leave that as it was, while passing the required
variables into a component, where another thread is started to load the
frmProgress_Bar. To try and simulate what I wanted to do I wrote a
simplified version of this:

1)    frmMain Load event calls a subprogram (Sub Index_Count) which indexes
an accumulator thru a timer to slow the loop down
            Component1.gsngCount = sngCount
            Component1.gsngEndVal = sngEndVal
            Passes my values to the component. This loops with the count,
with the mistaken thought that it would update the value in the component
continually while counting

2)      A Thread which is defined in my component is called (from Sub
Index_Count) , which starts the progress bar form (On the first loop only)

3)     The form load event for this form starts another thread, also defined
in the component
        This thread performs a RaiseEvent to pass the gsngCount and
gsngEndVal  values  thru a CountHandler in my ProgressBar form (which I was
hoping would continually update                         with the loops from
the first form load procedure (Sub Index_Count) which are still going on )

4)    BeginInvoke then passes this value thru a delegate into the sub which
updates my Progress bar

 I believe I can see why this isn't working. I just can come up with a
method that will make it work. (Yeah, I know that your probably thinking -
What the Hell is he doing? - But it's all I could come up with!)

Could someone please tell me what I need to be doing - I'm totally lost
here!
Or maybe direct me to a code sample. (I found a sample that does exactly
what I'm looking for, but unfortunately it was in C# and I couldn't quite
follow it {ASyncCalc_Pi})



Wed, 21 Sep 2005 08:45:58 GMT  
 Passing values between running threads ?
Hello,


Quote:
>  I believe I can see why this isn't working. I just can come up with a
> method that will make it work. (Yeah, I know that your probably thinking -
> What the Hell is he doing? - But it's all I could come up with!)

Have a look at this article:

http://www.devx.com/dotnet/Article/11358

Regards,
Herfried K. Wagner



Wed, 21 Sep 2005 08:54:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. threading - Multiple threads returning values at same time

2. Main report value<-pass/return->subReport values (ActiveX Designer Component 6.0)

3. Passing parameters to a thread

4. Passing data to a new thread

5. Passing objects to a thread

6. Passing attributes to Threads?

7. Passing Structure to a Thread function in VB

8. Passing/Copying an ADO recordset between threads...

9. Q: Threading and return values

10. VB.NET How Do I Run MDI-Child On Different Thread

11. Running a class in a seperate thread

12. Run a thread as another user

 

 
Powered by phpBB® Forum Software