Click here to Skip to main content
15,921,793 members
Home / Discussions / C#
   

C#

 
GeneralRe: windows not in focus Pin
Heinzzy17-Jan-10 5:50
Heinzzy17-Jan-10 5:50 
AnswerRe: windows not in focus Pin
wjp_auhtm17-Jan-10 5:27
wjp_auhtm17-Jan-10 5:27 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 5:28
michaelgr117-Jan-10 5:28 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:33
wjp_auhtm17-Jan-10 18:33 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 20:06
michaelgr117-Jan-10 20:06 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:24
wjp_auhtm17-Jan-10 21:24 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 21:35
michaelgr117-Jan-10 21:35 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:57
wjp_auhtm17-Jan-10 21:57 
If set the windows service autorun, when you restart computer, the service will start.

Of course, you can start the service in manual like this.

/// <summary>
/// TODO: Start windows service.
/// </summary>
/// <param name="name">The name of windows service.</param>
/// <returns>If success return true,or return false.;</returns>
private bool StarmyService(string name)
{
    ServiceController sc = new ServiceController(name);
    if (sc.Status == ServiceControllerStatus.Stopped || sc.Status == ServiceControllerStatus.StopPending
            )
    {
        sc.Start();
        sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10));
    }
    else
    {
    }
    sc.Close();
    return true;
}


And stop the service like this

/// <summary>
/// TODO: Stop windows service.
/// </summary>
/// <param name="name">The name of windows service.</param>
/// <returns>If success return true,or return false.;</returns>
private bool StopmyService(string name)
{
    ServiceController sc = new ServiceController(name);
    if (sc.Status == ServiceControllerStatus.Running ||
        sc.Status == ServiceControllerStatus.StartPending)
    {
        sc.Stop();
        sc.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 10));
    }
    else
    {
    }
    sc.Close();
    return true;
}

GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:00
michaelgr117-Jan-10 22:00 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:26
wjp_auhtm17-Jan-10 22:26 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:39
michaelgr117-Jan-10 22:39 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:57
wjp_auhtm17-Jan-10 22:57 
GeneralRe: windows not in focus Pin
Heinzzy18-Jan-10 3:51
Heinzzy18-Jan-10 3:51 
GeneralRe: windows not in focus Pin
wjp_auhtm18-Jan-10 14:21
wjp_auhtm18-Jan-10 14:21 
GeneralRe: windows not in focus Pin
Ravi Bhavnani17-Jan-10 9:26
professionalRavi Bhavnani17-Jan-10 9:26 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:41
wjp_auhtm17-Jan-10 18:41 
AnswerRe: windows not in focus Pin
Heinzzy17-Jan-10 5:47
Heinzzy17-Jan-10 5:47 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 6:40
michaelgr117-Jan-10 6:40 
QuestionHow to reject changes between two equal DataTables? Pin
obarahmeh16-Jan-10 21:13
obarahmeh16-Jan-10 21:13 
AnswerRe: How to reject changes between two equal DataTables? Pin
dan!sh 16-Jan-10 21:20
professional dan!sh 16-Jan-10 21:20 
QuestionUSB read Pin
michaelgr116-Jan-10 20:39
michaelgr116-Jan-10 20:39 
AnswerRe: USB read Pin
Alex Manolescu16-Jan-10 21:24
Alex Manolescu16-Jan-10 21:24 
QuestionMicrosoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 20:28
Mohammad Dayyan16-Jan-10 20:28 
AnswerRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
dan!sh 16-Jan-10 21:15
professional dan!sh 16-Jan-10 21:15 
GeneralRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 21:21
Mohammad Dayyan16-Jan-10 21:21 

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.