View Single Post
  #1 (permalink)  
Old January 30th, 2006, 04:18 AM
rodmcleay rodmcleay is offline
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default Service Starts and Stops

Hi all,
I have created a windows service with .net 2.
I have installed the service but when I try to start it I get a message that the service has started and stopped as there was nothing to do.
I have noticed from some other similar problems on the net that this may be due to a thread not being started for each service.
There are three seperate services that I wish to run in this process and I have started them all from the program page like so:
Code:
static void Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { 
                new SmsReceive(), 
                new SmsSend(),
                new SmsRouting()
            };
            ServiceBase.Run(ServicesToRun);
        }
In each of the services there is code like so:
Code:
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            PortUtilities.OpenPort(serialPort, ReceiveGsmModemPort);
            serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
            Watch();            
        }
SO each has some kind of loop to continue watching either a GSM Modem or a Message Queue.

How can I get these services running in processes that will not stop?

Many thanks for your time in advance.
Rod


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
Reply With Quote