开发者

In Silverlight, will navigating away from the page that contains a thread end the thread?

I have a Silverlight 3 project. When one of the pages is loaded, a System.Threading.Thread object is created and started. I want to make sure that it terminates when the user navigates away from the page. Will this happen automat开发者_开发百科ically, or do I have to manually terminate the thread in the OnNavigatingFrom event?

Thanks for any help.


The Thread object can be destroyed but the process thread it created will continue to run until the method that it originally invoked returns.

So if you have some code in some loop that never returns that thread will continue until you do something to interrupt that loop, regardless of what you do with the Thread object that created it. IMO the class Thread is a bit of a mis-nomer.


Nope, A thread will keep on living even if there are no references to it.

Maybe, instead of using a thread (which I can only assume has a repeating operation) you can set a timer that queues that operation to the threadpool. the timer will stop executing the operation once you exit the page and you will have more control over your system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜