Click here to Skip to main content
15,892,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can i read pdf file in .net? Pin
sush827-Jul-10 1:06
sush827-Jul-10 1:06 
QuestionSetup project help Pin
TSWatson26-Jul-10 22:47
TSWatson26-Jul-10 22:47 
AnswerRe: Setup project help Pin
N a v a n e e t h27-Jul-10 0:56
N a v a n e e t h27-Jul-10 0:56 
AnswerRe: Setup project help [Repost] Pin
Peace ON27-Jul-10 2:36
Peace ON27-Jul-10 2:36 
QuestionGlobalization and Localization in common dll C# Pin
ISharda26-Jul-10 22:41
ISharda26-Jul-10 22:41 
AnswerRe: Globalization and Localization in common dll C# Pin
Peace ON27-Jul-10 0:59
Peace ON27-Jul-10 0:59 
QuestionTo use or not to use worker thread in Windows Service? Pin
JoeSchmoe00726-Jul-10 8:39
JoeSchmoe00726-Jul-10 8:39 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
Luc Pattyn26-Jul-10 8:43
sitebuilderLuc Pattyn26-Jul-10 8:43 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
JoeSchmoe00726-Jul-10 8:47
JoeSchmoe00726-Jul-10 8:47 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
Luc Pattyn26-Jul-10 8:49
sitebuilderLuc Pattyn26-Jul-10 8:49 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
PIEBALDconsult26-Jul-10 8:51
mvePIEBALDconsult26-Jul-10 8:51 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
JoeSchmoe00726-Jul-10 9:00
JoeSchmoe00726-Jul-10 9:00 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
PIEBALDconsult26-Jul-10 9:20
mvePIEBALDconsult26-Jul-10 9:20 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
Gonzalo Cao26-Jul-10 20:46
Gonzalo Cao26-Jul-10 20:46 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
Chris Trelawny-Ross27-Jul-10 5:37
Chris Trelawny-Ross27-Jul-10 5:37 
GeneralRe: To use or not to use worker thread in Windows Service? Pin
Gonzalo Cao27-Jul-10 8:28
Gonzalo Cao27-Jul-10 8:28 
AnswerRe: To use or not to use worker thread in Windows Service? Pin
RugbyLeague26-Jul-10 23:34
RugbyLeague26-Jul-10 23:34 
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/ ?

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.