ouaipdu53
Messages postés4Date d'inscriptionsamedi 26 mars 2005StatutMembreDernière intervention25 mai 2008
-
25 mai 2008 à 11:30
cs_coq
Messages postés6349Date d'inscriptionsamedi 1 juin 2002StatutMembreDernière intervention 2 août 2014
-
25 mai 2008 à 16:11
Bonjour ,
Dans le cadre de la réalisation d'un logiciel de supervision, je dois crée une application multi-clients. Pour gérer cela, chaque client possède donc une socket de communication associée à un Thread. Mon problème survient lorsque je souhaite quitter mon application : un Thread "tourne" toujours en arrière plan. Ce comportement est du, je pense, à la méthode "receiv" (méthode bloquante). Est-il possible de la débloquer n'importe quand afin de détruire le Thread associé ?
cs_coq
Messages postés6349Date d'inscriptionsamedi 1 juin 2002StatutMembreDernière intervention 2 août 2014101 25 mai 2008 à 16:11
Salut,
C'est dit dans la section remarques :
"A thread is either a background thread or a foreground thread. Background threads are identical to foreground threads, except that background threads do not prevent a process from terminating. Once all foreground threads belonging to a process have terminated, the common language runtime ends the process. Any remaining background threads are stopped and do not complete."
"Un thread est soit un thread d'arrière-plan, soit un thread de premier plan. Les threads d'arrière-plan sont identiques aux threads de premier plan, sauf qu'ils n'empêchent pas un processus de s'arrêter. Une fois que tous les threads de premier plan appartenant à un processus sont terminés, le Common Language Runtime met fin au processus. Tous les threads d'arrière-plan restants sont arrêtés et ne se terminent pas."
Après tu peux aussi opter pour arrêter les threads toi même, naturellement.
ouaipdu53
Messages postés4Date d'inscriptionsamedi 26 mars 2005StatutMembreDernière intervention25 mai 2008 25 mai 2008 à 16:04
D'après MSDN, cette propriété permet de définir si le thread est un thread d'arrière plan ou non. Pourrais-tu m'expliquer pourquoi le fait de mettre le thread comme étant un thread d'arrière plan permettrai de résoudre mon problème... Je ne vois pas très bien la relation.