Hi ,
I Copied Full code from My WIndows Application to Windows Server .
But I Dont Know how to Call My Method in OnStart Method in Windows Service.
I tried By Calling My Method Under On Start (string[] arg).
My Windows Application is working Perfectly , But Windows Service is Not
working at all.
Any Help is Greatly Appreciated as per as possible.
Thanks & Regards,
Tirupati
Loading
tiru johnPosted Jan 21, 2011, 3:02 AM
I want to call this method when service starts.
i tried with calling Method in Start , but it is not working.
and i also want to know that how to RESTART Scheduled Task in every minute.
i gave 1 Minute in Repeat task but its not updating Next Runtime and LastRunTime.
Pls Help Me.
Thanks,
Tirupati
Soft CornerPosted Jan 21, 2011, 1:52 AM
Implement your method like this in class .. it will work
public void GetFilesInFolder()
{
}
tiru johnPosted Jan 21, 2011, 1:05 AM
here i want to call the Method (GetFilesInFolder() )in Start.
but its Not working if i call like this.
protected override void OnStart(string[] args)
{
GetFilesInFolder();
}
Please Explain in Detail how to call this Method.
Thanks,
Tirupati
Soft CornerPosted Jan 21, 2011, 12:47 AM
If u want to call a Method only in Windows Service,then Start the service first and implement OnCustomCommand . In this U can Build different Codes.
e.g :-
In Windows Service :-
public enum SimpleServiceCustomCommands { Method1 = 128, Method2 =129, Method3 =130};
protected override void OnCustomCommand(int command)
{
base.OnCustomCommand(command);
switch(command)
{
case(int)SimpleServiceCustomCommands.Method1 :
//Implement Code
break;
case(int)SimpleServiceCustomCommands.Method2 :
//Implement Code
break;
case(int)SimpleServiceCustomCommands.Method3 :
//Implement Code
break;
default:
break;
}
}
-------------------
Now Call this Commands as a Method from Outside :-
ServiceController Controller = new ServiceController("TranslationService");
Controller.Refresh();
if (Controller.Status == ServiceControllerStatus.Stopped)
{
Controller.Start();
}
----- Implement below code when u want to call ur Commands (as methods) -------------
if (Controller.Status == ServiceControllerStatus.Running)
{
Controller.ExecuteCommand(128); //Command parameters 128,129,130
}
-------------
Hope this will help you