mobile service not quit in windows mobile 6 even when i call Quit() method

Jun 19, 2009 at 1:39 PM

Hi all

         i have created service by extending ServiceApplication.

1. it is working fine but  even  when i used Quit() service still running...............

Please any one give the solution as soon as possible.

 

Thanks In advance.

Nagarjun

 

 

Jun 22, 2009 at 5:31 AM

Hi,

are you using additional threads within your Service?

Quit works fine in general terms, so it would be interesting to know, what you've been doing.

 

Cheers, Peter

Jun 22, 2009 at 7:15 AM
Edited Jun 22, 2009 at 7:17 AM

Hi

       this is the service class i have written

class SampleService : ManagedService.ServiceApplication
    {
        private static SampleService service = new SampleService();       

        SystemState systemState = new SystemState(SystemProperty.Time);


        private SampleService()
        {          
            ServiceGuid = Guid.NewGuid();
            ServiceName = "SampleServiceTest";
            systemState.Changed += new ChangeEventHandler(systemState_Changed);
           
        }

        void systemState_Changed(object sender, ChangeEventArgs args)
        {
            MessageBox.Show("In statechanged");
        }

        public static SampleService GetInstance()
        {
            return service;
        }


    }

 

In form i have taken two buttons start and stop.

in start button click  this code 

SampleService.GetInstance().Start();

 

in stop buttton click this code

SampleService.GetInstance().Quit();

when i click stop button service state is showing Exited. but  MessageBox.Show("In statechanged");  displayed contuniously untill i close the from.

please replay as soon as possible. very urgent.....

regards,

nagarjun.p

 

 

Jun 22, 2009 at 8:13 AM

Hi,

it looks like you haven't implemented it properly. It looks like you have added a Form to your Service Project, or you have added a reference to your Service, which is wrong.

A service itself is supposed to be independently working. Therefore, as you have a refenerence to your Service, it is obvious, that the service can't quit.

You shall take a look at the Service Manager, which is available as source as well, where you will see, how that application is working with general service, as it uses WM Messages to communicate with a service.

You shall take an additional look at the WIKI-documentation within this project page to learn more about services and the architecture behind.

Cheers, Peter

Jun 22, 2009 at 12:53 PM
Edited Jun 22, 2009 at 12:56 PM

Hi ,,,

thankyou for your earlier replay.  i wrote the service as mentioned in this http://managedserviceswm.codeplex.com/Wiki/View.aspx?title=How%20to%20create%20and%20extend%20a%20simple%20Managed%20Services%20for%20Windows%20Mobile&referringTitle=Home

i am able to start the service  and stop the service through Managed services console.  

I am new to Mobile development and .net   . can you send the code   Quit ()  the service programatically.

 

Thanks in Advance,

Nagarjun.P.

 

 

Jun 24, 2009 at 11:15 AM

Hi ,

 

              i did example as metioned in sample. To start the service i have created singleton design pattern To get the instance. In that instance i called Start() method in Main().

if it is correct . i called Quit() method on the same instance but  service  is running continuously.

 

Thanks and regards,

Nagarjun.P.