Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Check for an enpty picturebox control Pin
Giorgi Dalakishvili4-Feb-08 22:20
mentorGiorgi Dalakishvili4-Feb-08 22:20 
QuestionUsing Offline Application Block Pin
Søren Christensen4-Feb-08 21:38
Søren Christensen4-Feb-08 21:38 
QuestionHow to display data dynamically Pin
NarVish4-Feb-08 20:25
NarVish4-Feb-08 20:25 
AnswerRe: How to display data dynamically Pin
J a a n s4-Feb-08 21:24
professionalJ a a n s4-Feb-08 21:24 
GeneralRe: How to display data dynamically Pin
NarVish6-Feb-08 23:20
NarVish6-Feb-08 23:20 
Generaldatalist paging with master pages Pin
chithra.r4-Feb-08 19:42
chithra.r4-Feb-08 19:42 
GeneralRe: datalist paging with master pages Pin
J a a n s4-Feb-08 21:16
professionalJ a a n s4-Feb-08 21:16 
GeneralWindows Service Pin
CodingLover4-Feb-08 19:04
CodingLover4-Feb-08 19:04 
Hi all,

I want to write a Windows Service using C#. I want to execute the following function after a specified time.

private void ServerStat(object state)
{
    //Console.WriteLine("Text");

    const string appName = "groupserver.exe";
    RegistryKey rKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Nqual\\Common");

    try
    {
        string appPath = rKey.GetValue("serverLocation").ToString() + "bin\\";

        ProcessStartInfo ps = new ProcessStartInfo(appPath + appName);
        ps.UseShellExecute = true;
        ps.WorkingDirectory = appPath;
        System.Diagnostics.Process.Start(ps);
    }
    catch(Win32Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}


Edit the OnStart() as follows.

protected override void OnStart(string[] args)
{
    // TODO: Add code here to start your service.
    TimerCallback timerDelegate = new TimerCallback(ServerStat);

    serviceTimer = new Timer(timerDelegate, null, 5000, 5000);
}


Install the service and start the service. But my function not execute. Where I'm going wrong. Help really appreciate. Thanks.

I appreciate your help all the time...
Eranga Smile | :)

GeneralRe: Windows Service Pin
CKnig4-Feb-08 20:02
CKnig4-Feb-08 20:02 
GeneralRe: Windows Service Pin
CodingLover4-Feb-08 21:06
CodingLover4-Feb-08 21:06 
GeneralRe: Windows Service Pin
Vikram A Punathambekar4-Feb-08 21:51
Vikram A Punathambekar4-Feb-08 21:51 
GeneralRe: Windows Service Pin
CKnig4-Feb-08 22:10
CKnig4-Feb-08 22:10 
GeneralRe: Windows Service Pin
CodingLover5-Feb-08 0:03
CodingLover5-Feb-08 0:03 
Questionhow to make my own controls in c# Pin
E_Gold4-Feb-08 18:30
E_Gold4-Feb-08 18:30 
AnswerRe: how to make my own controls in c# Pin
sindhutiwari4-Feb-08 18:41
sindhutiwari4-Feb-08 18:41 
AnswerRe: how to make my own controls in c# Pin
Ajay.k_Singh4-Feb-08 19:00
Ajay.k_Singh4-Feb-08 19:00 
QuestionTCP/IP Keep Alive Time [modified] Pin
sindhutiwari4-Feb-08 18:23
sindhutiwari4-Feb-08 18:23 
QuestionAvoid Duplicate Entry in Text File Pin
D i x y4-Feb-08 17:55
D i x y4-Feb-08 17:55 
GeneralRe: Avoid Duplicate Entry in Text File Pin
Christian Graus4-Feb-08 18:01
protectorChristian Graus4-Feb-08 18:01 
GeneralRe: Avoid Duplicate Entry in Text File Pin
Adeel Chaudhry4-Feb-08 18:09
Adeel Chaudhry4-Feb-08 18:09 
GeneralRe: Avoid Duplicate Entry in Text File Pin
Adeel Chaudhry4-Feb-08 18:06
Adeel Chaudhry4-Feb-08 18:06 
GeneralRe: Avoid Duplicate Entry in Text File Pin
D i x y4-Feb-08 19:43
D i x y4-Feb-08 19:43 
AnswerRe: Avoid Duplicate Entry in Text File Pin
Vikram A Punathambekar4-Feb-08 19:58
Vikram A Punathambekar4-Feb-08 19:58 
GeneralRe: Avoid Duplicate Entry in Text File Pin
Christian Graus4-Feb-08 19:59
protectorChristian Graus4-Feb-08 19:59 
Generalobject references Pin
amit_834-Feb-08 17:40
amit_834-Feb-08 17:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.