The trick is to use Jon's idea, not his code. Let's suppose that you have a window with a listbox in it. Drop a Timer onto the window.

Next, suppose that the thread object constructs a ListboxDataObject in its Run event handler. Add a function ListboxData() as ListboxDataObject. Initially, this property is nil. The Run event handler builds the ListboxDataObject and stores it in a private property that you access using the ListboxData function.

Now add a method BeginBuildListbox with the following implementation.

Sub BeginBuildListbox()
  self. ListboxThread = new ListboxDataObjectThread
  self.ListboxThread.Run
  Timer1.Mode = Timer.ModeMultiple
  Timer1.Period = 500
End Sub

Implement the Timer's Action event handler as follows.

Sub Action()
  If self.ListboxThread is nil then
    Return //because the timer shouldn't have been started
  End if

  If self.ListboxThread.ListboxData <> nil then //thread complete
    me.Mode = Timer.ModeOff
    BuildListbox Listbox1, self.ListboxThread.ListboxData
    self.ListboxThread = nil
 Else
    //thread is still working
  End if
End Sub

BuildListbox is a method that fills the Listbox with the data.

Charles Yeomans


On Mar 21, 2006, at 1:20 PM, Jay Rimalrick wrote:

Are you talking about another external timer or the
ProgressTimer?  The ProgressThread "kills" the
ProgressTimer with mTimer = nil so how do you know the
ProgressTimer will see the ProgressThread finish?  I
could populate the listbox right after the RunThread
call in ProgressThread's run method but that seems to
break modularity.

Thanks for your help,
Jay

--- Charles Yeomans <[EMAIL PROTECTED]> wrote:

Sure it solves your problem.  In the timer, check
the state property of
the thread, as Joe Strout suggested.  When the
thread has finished,
then the timer can use the data object, or call some
method that does.

Charles Yeomans

On Mar 21, 2006, at 12:57 PM, Jay Rimalrick wrote:

I am familiar with that post but I don't think it
solves my problem.  That post shows how to update
a
progress indicator.  What I have is a thread that
is
populating a data object and I want to make sure
the
thread is finished before I use the data object.
Does
that make sense?

Jay

--- Charles Yeomans <[EMAIL PROTECTED]>
wrote:

Ah.  This is a question that can be answered. See
<http://www.nilobject.com/?p=233> for a very good
discussion of this
problem.

Charles Yeomans

On Mar 21, 2006, at 12:39 PM, Jay Rimalrick
wrote:

Ultimately I want a thread to gather some data
and
when the thread is finished I want a listbox to
be
populated with the data.  I guess I could hard
code
the second part into the thread, but I was
wondering
if there was a way in the listbox to say, "when
thread
x thread is finished go ahead and populate
yourself."

Thanks,
Jay

--- Norman Palardy
<[EMAIL PROTECTED]>
wrote:


On Mar 21, 2006, at 9:16 AM, Charles Yeomans
wrote:

But wouldn't this event handler be invoked in
the
thread, as opposed
to the other thread that wants to know when
this
specific thread is
finished?

I suppose, but he said nothing about other
threads,
just that he wants
to do something when the thread finishes

I want to do something, but only after a
specific
thread is finished.  Is there a way to detect
exactly
when a thread finishes (from outside of the
thread)?

Depending on the exact requirements there are
many
possible solutions,
some of which may suit his needs better than
others.


_______________________________________________
Unsubscribe or switch delivery mode:


<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:





<http://support.realsoftware.com/listarchives/lists.html>




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around
http://mail.yahoo.com
_______________________________________________
Unsubscribe or switch delivery mode:

<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:




<http://support.realsoftware.com/listarchives/lists.html>


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:

<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:



<http://support.realsoftware.com/listarchives/lists.html>



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around
http://mail.yahoo.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:


<http://support.realsoftware.com/listarchives/lists.html>


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:

<http://support.realsoftware.com/listarchives/lists.html>



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to