Will Silverlight navigate from the page containing the thread, end of thread?

I have a Silverlight 3 project. When one of the pages loads, a System.Threading.Thread object is created and launched. I want to make sure it exits when the user navigates from the page. Will this happen automatically or will I have to manually terminate the stream in the OnNavigatingFrom event?

Thanks for any help.

+4
source share
2 answers

The Thread object may be destroyed, but the process thread it created will continue to work until the method that it originally called returns.

So, if you have some code in some loop that never returns this thread, it will continue until you do something to interrupt this loop, no matter what you do with the created im Thread object. IMO's Thread class is a bit wrong.

+2
source

No, the stream will continue to live, even if it has no links.

Perhaps instead of using a thread (which I can only assume has a repeating operation), you can set a timer that puts this operation in threadpool. the timer will stop the operation as soon as you exit the page and you will have more control over your system.

+1
source

All Articles