Re: Thread ending
- From: "Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx>
- Date: Wed, 22 Nov 2006 06:00:03 GMT
"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:uN6PZZfDHHA.4740@xxxxxxxxxxxxxxxxxxxxxxx
Jon,
Why you want to restart it, a thread is removed by the system when it is
ready, just start a new thread is more normally done.
Can you tell us therefore what is the reason for you to restart it.
The thread computes some stuff. For simplicity lets suppose it is to compute
the primes between two numbers. Now the user selects the numbers in a gui
and might decide to change them(lets suppose the computation takes long
enough to do so that its not finished before he decides to change).
So I don't want to start another thread that computes the new primes while
the old one is going on. Neither do I want to suspend the old one because
then it stops it in the middle... it doesn't free resources or anything.
I basically want to call GeneratePrimes(a,b); when the user wants to see
them but I need to do it in the background so the user can do some other
stuff. Theres no need, say, for the user to wait 10 mins(hypothetically) if
he realizes that he ment to use the interval [10,1000] instead of [10,100]
which is what he put in. So he either waits or closes the app.
Seems better that when he enters a new interval a new computation is started
and the old one is ended and the results would be disregarded since the user
didn't want them.
One issue, which isn't a problem the way I have it setup, is how the
threads actually work. I think this is called re-entry, what I mean is that
the function might be in the middle of a computation when another thread
starts a new computation without stopping the original thread. Here if its
not programmed properly then bad things could happen. I suppose this is why
locks and stuff are important. But one thing I'm wondering is if the thread
somehow copies the code to a new block so all local data is duplicated.
Although I think that stuff has to do with the apartment model or whatever?
Main thing is I just need to "stop" the thread and "restart" it on new
parameters but everywhere I read says that abort is not the way to go yet
there is no stop method for threads. So maybe the stop is implied by a
suspension of the thread and then no reference to it so that the GC cleans
it up? But the suspend() is depreciated in 2.0 ;/ Seems the only thing I'm
left with is abort ;/
Thanks,
Jon
.
- Follow-Ups:
- Re: Thread ending
- From: Tom Shelton
- Re: Thread ending
- References:
- Thread ending
- From: Jon Slaughter
- Re: Thread ending
- From: Cor Ligthert [MVP]
- Thread ending
- Prev by Date: Re: User control constructor called twice
- Next by Date: Re: GUI Buttons like VISTA
- Previous by thread: Re: Thread ending
- Next by thread: Re: Thread ending
- Index(es):