In a multi-threaded application, it becomes very important to decide whether a thread will be a foreground thread or a background thread, specially if it is an unattended process, otherwise the program may continue to run even when it is not required.
Difference between the two is that a foreground thread runs until it is complete and does not allow the application or program to terminate before its termination. On the contrast, a background thread is immediately terminated whenever the application is terminated or all foreground threads belonging to the application are terminated.
In .NET we set a thread as a background thread or as a foreground thread by setting the property 'Thread.IsBackground' to true, for background, or false to indicate a foreground thread.
For example I have an applicaton that keeps a watch on my mailbox and alerts me whenever I receive a mail. For this purpose when the application starts, it starts a thread which keeps on polling to my mail server at a regular interval and checks for new mail. When I shut down this application, I would also want this thread to stop polling to the mail server. If this thread has been set as a background thread, it will be stopped automatically once I shut down the application. But, if this thread has been set as a foreground thread, then the application needs to have some logic in the method, which is running on this thread, to terminate when the application is requested to quit.
-
5 comments:
Did they cut out parts of the book on the iphone application?
[url=http://forexrobot-review.info]best forex software[/url] [url=http://x-vietnam.polytechnique.org/index.php?option=com_zoom&Itemid=61&page=view&catid=1&key=2&vote=2&PHPSESSID=4896d485cccd0ae6569747bcfeef3711]unlock iphone[/url]
Predilection casinos? travel sure of this trendy [url=http://www.realcazinoz.com]casino[/url] instruction and take up online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also testify to our different [url=http://freecasinogames2010.webs.com]casino[/url] orientate at http://freecasinogames2010.webs.com and flourish in authentic incredibly long-way-off !
another additional [url=http://www.ttittancasino.com]casino spiele[/url] in the region of is www.ttittancasino.com , in come back german gamblers, submit c be communicated by means of safe from online casino bonus.
on the other side of 21 and needful of straits some of shrewdness toys? pick up at [url=http://www.avi.vg]sex toys [/url] online, husky verse of of of seniority toys like [url=http://www.avi.vg/category.php?a=coition4sexx&cid=3]vibrators [/url] and [url=http://www.avi.vg/category.php?a=having it away4sexx&cid=30]dildos [/url]at www.avi.vg , acquiring do location the despatch, another inspirited purlieus to grip [url=http://www.ewgpresents.com]viagra online[/url] is the all up to time http://www.ewgpresents.com and the elevated ed rx [url=http://www.rxpillsmd.net]online viagra[/url] apothecary www.rxpillsmd.net , and the dynamic generic [url=http://www.generic4you.com]viagra[/url] apothecary at www.generic4you.com or at www.generik4u.com the [url=http://www.generik4u.com]sildenafil citrate[/url] shop.
Hello. My wife and I bought our house about 6 months ago. It was a foreclosure and we were able to get a great deal on it. We also took advantage of the 8K tax credit so that definitely helped. We did an extensive remodeling job and now I want to refinance to cut the term to a 20 or 15 year loan. Does anyone know any good sites for mortgage information? Thanks!
Mike
Hello!
My name is Tom, Im 38 yrs old, living in Fort Worth, TX.
I'd love to make good close friends here.
Waiting your reply..
Post a Comment