When is a thread complete? 
Author Message
 When is a thread complete?

I'm sure this question has a simple answer, but I'm tired of beating my head
against the wall so I'll ask it.
When I start a thread from the frame, how can I tell when it has completed?
I need to perform some logic when the thread is done but I don't know where
or how to do this.
What is the main frame doing while another thread is running?

Any help would be greatly appreciated.

Thanks - Ed Campbell
Using C5b - Abc



Tue, 10 Feb 2004 15:33:02 GMT  
 When is a thread complete?
Hi Ed,

The frame does not know when the thread is complete.
If the frame has to do somethign when the thread is finished, then as a last
dying act <g> the thread should POST and event (Event:user say) back to the
frame. ie
Post(Event:User,,1)

Note the 2 commas (since it's not going to any specific control) and I've
hard-coded the frame to thread 1. Probably not great. A better thing would
be;
a) create global _non threaded_ varible called Mainthread.
b) In init of Frame put MainThread = Thread()
c) in other proc put  Post (Event:User,,MainThread)
d) in TakeEvent of Frame put
if event() = Event:User
  ! other thread just finished...
end

Lastly...

Quote:
> What is the main frame doing while another thread is running?

It's stll going. It's probably sitting on the ACCEPT command wating for
events to process...

Cheers
Bruce


Quote:
> I'm sure this question has a simple answer, but I'm tired of beating my
head
> against the wall so I'll ask it.
> When I start a thread from the frame, how can I tell when it has
completed?
> I need to perform some logic when the thread is done but I don't know
where
> or how to do this.
> What is the main frame doing while another thread is running?

> Any help would be greatly appreciated.

> Thanks - Ed Campbell
> Using C5b - Abc



Tue, 10 Feb 2004 15:51:35 GMT  
 When is a thread complete?
Ed,

What Bruce said: Posting an event back to the AppFrame from
the ClosingWindow embed of the window in the started thread.

But, if you want to know for all started threads, you'll have to make
a user event for every proc, to distinguise them, or ...
Install one of the (free) thread-limiters and look how they work.
You have one from Locus, who sets up a seperate global variable
for every proc in your app. Or the one from ABC-Free, which sets
up a global queue, in which it stores the proc-names when started.
With either of those, you can check in the timer embed of your
AppFrame if this variable/queue is still filled: if it is, the thread is
still running.

--

Best regards,
Maarten
CDD3.1, C5EEb - ABC & C5.5.04EE
Certainly Clarion Developer



Wed, 11 Feb 2004 03:00:05 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do you hide a complete thread?

2. Possibly OT: Waiting for threads to complete...

3. Thread terminating a complete program ?

4. Threads creating threads creating threads...

5. thread, threading, mutex modules and non-threading interpreters

6. I am not deaf, but am I mute?

7. Non-threaded function in a threaded recursion?

8. Thread.new vs. Thread.start

9. Thread#kill doesn't kill processes inside a thread

10. meditations on threads and thread safety

11. Tkinter and thread (or thread and Tkinter...)

12. threading.Thread.join(timeout=...) considered unreliable

 

 
Powered by phpBB® Forum Software