Information générale
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Network:
Windows 2003 Server
>Hello Keith,
>
>>> Does the service need the "never-ending stuff" to intialize?
>
>No, the service initializes, then goes into a never-ending loop. More precisely, it listenens for socket connections. So what I'm doing now is initializing in OnStart, then start a thread (also in OnStart). The thread's method is a never-ending loop that blocks on Socket.Listen, then continues once a connection is accepted, loops and waits for the next connection.
>
>Is this the same idea as your suggestion?
>
>Thanks,
>Mike
Mike,
Not really.
But to use this "properly" as a windows service is going to take a little re-writing. It would work a lot better if you used a timer in the service and polled the socket periodically rather than blocking on the port. If the Socket class has a "peek" method, you could launch the new thread only when there is a new connection and new data available. Once you start a thread, you have very limited control over its lifetime from the process that started it.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement