Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
N a v a n e e t h27-Jul-10 0:54
N a v a n e e t h27-Jul-10 0:54 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
JoeSchmoe00727-Jul-10 3:04
JoeSchmoe00727-Jul-10 3:04 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
N a v a n e e t h27-Jul-10 4:51
N a v a n e e t h27-Jul-10 4:51 
QuestionResolved C# Socket programming with linux machine. [modified] Pin
jobin00700726-Jul-10 5:10
jobin00700726-Jul-10 5:10 
AnswerRe: C# Socket programming with linux machine. Pin
Richard MacCutchan26-Jul-10 6:13
mveRichard MacCutchan26-Jul-10 6:13 
AnswerRe: C# Socket programming with linux machine. Pin
PIEBALDconsult26-Jul-10 7:21
mvePIEBALDconsult26-Jul-10 7:21 
AnswerRe: Resolved C# Socket programming with linux machine. Pin
jobin00700727-Jul-10 5:33
jobin00700727-Jul-10 5:33 
QuestionWindows or Console application target for Windows Service? Pin
JoeSchmoe00726-Jul-10 3:43
JoeSchmoe00726-Jul-10 3:43 
When Windows Service application is created by VS 2008 via "Windows Service" template it is created as Windows application ( /target:winexe)

For convenience of debugging I modified it so that it can be started both from the command line and as a service using this approach:

static void Main(string[] args)
{
    ServiceBase[] ServicesToRun;
    TestService srv = new TestService();
    ServicesToRun = new ServiceBase[]
    {
        srv
    };
    if (Environment.UserInteractive)
    {
        char KeyChar;
        srv.ManualStart(args);
        Console.WriteLine("Service started in console mode, press Space key to stop");
        Console.WriteLine("Press any letter or digit to send control command (ASCII code +128)");
        while (true)
        {
            KeyChar = Console.ReadKey().KeyChar;
            Console.WriteLine("");

            if (KeyChar == ' ')
                break;
            else
            {
                srv.ManualCustomCommand(KeyChar + 128);
            }

        }

        srv.ManualStop();

    }
    else
        ServiceBase.Run(ServicesToRun);
}


In order for this to work as expected I had to change output type from "Windows Application" to "Console Application" ( /target:exe). Everything currently works the way I expect.

Is this acceptable for Windows Service to be compiled as Console application? Are there any implications? Should I have kept it as "Windows Application" and attached console to it using approach described here: http://www.csharp411.com/console-output-from-winforms-application/ ?
AnswerRe: Windows or Console application target for Windows Service? Pin
darkelv26-Jul-10 4:04
darkelv26-Jul-10 4:04 
AnswerRe: Windows or Console application target for Windows Service? [modified] Pin
PIEBALDconsult26-Jul-10 6:55
mvePIEBALDconsult26-Jul-10 6:55 
QuestionMouse Hover/Leave with many controls and status strip message Pin
Blubbo26-Jul-10 3:05
Blubbo26-Jul-10 3:05 
AnswerRe: Mouse Hover/Leave with many controls and status strip message Pin
Blubbo26-Jul-10 4:16
Blubbo26-Jul-10 4:16 
QuestionFTP transfer corrupts .PNG files Pin
anthasaurus26-Jul-10 2:06
anthasaurus26-Jul-10 2:06 
AnswerRe: FTP transfer corrupts .PNG files Pin
Nagy Vilmos26-Jul-10 2:18
professionalNagy Vilmos26-Jul-10 2:18 
GeneralRe: FTP transfer corrupts .PNG files Pin
anthasaurus26-Jul-10 23:10
anthasaurus26-Jul-10 23:10 
QuestionSelection Formula in crystal report Pin
Nikhil Bhivgade26-Jul-10 1:21
professionalNikhil Bhivgade26-Jul-10 1:21 
QuestionWhat API to use? Pin
c242326-Jul-10 0:54
c242326-Jul-10 0:54 
AnswerRe: What API to use? Pin
Eddy Vluggen26-Jul-10 1:19
professionalEddy Vluggen26-Jul-10 1:19 
GeneralRe: What API to use? Pin
c242326-Jul-10 1:28
c242326-Jul-10 1:28 
GeneralRe: What API to use? Pin
Eddy Vluggen26-Jul-10 1:41
professionalEddy Vluggen26-Jul-10 1:41 
GeneralRe: What API to use? Pin
c242326-Jul-10 3:08
c242326-Jul-10 3:08 
GeneralRe: What API to use? Pin
Eddy Vluggen26-Jul-10 3:11
professionalEddy Vluggen26-Jul-10 3:11 
GeneralRe: What API to use? PinPopular
Pete O'Hanlon26-Jul-10 3:51
mvePete O'Hanlon26-Jul-10 3:51 
GeneralRe: What API to use? Pin
c242326-Jul-10 5:32
c242326-Jul-10 5:32 
Questionbackground image for richtextbox like watermark Pin
mobasher26-Jul-10 0:45
mobasher26-Jul-10 0:45 

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.