Esempio n. 1
0
        protected override void OnStop()
        {
            base.OnStop();

            //TODO: clean up any variables and stop any threads
            FileSystemWriter.WriteSomething("stopped");
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            //This is where we'll create an instance of our service and tell it to run.
            ServiceBase.Run(new Program());

            if (args.Length != 0)
            {
                if (args[0] == "steveZOMBO")
                {
                    //Console.WriteLine("BEGIN  - Windows Service Timer Demo:");
                    FileSystemWriter.WriteSomething("BEGIN  - Windows Service Timer Demo:");
                    //--Fun with Timers and Windows Services
                    // Wait for user
                    //Console.WriteLine("Writing something to file system:");
                    // Create a timer with a ten second interval.
                    var aTimer = new System.Timers.Timer(2000);

                    // Hook up the Elapsed event for the timer.
                    aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
                    aTimer.Enabled  = true;

                    // Console.WriteLine("END  - Windows Service Timer Demo:");
                    FileSystemWriter.WriteSomething("END  - Windows Service Timer Demo:");
                }
                else
                {
                    FileSystemWriter.WriteSomething(string.Format("\n this will print one time and then not any more, and myArgs was {0}", args[0]));
                }
            }
            else
            {
                //----------------------------------------------------------------------------------------

                ScreenHelper.Welcome();
                ScreenHelper.ListOptions();

                while (true)
                {
                    //ScreenHelper.WritePrompt();
                    var userResponse = Console.ReadLine();
                    CommandManager.ParseCommand(userResponse);
                }


                //----------------------------------------------------------------------------------------
                //Variable Initialization crap:
                //http://stackoverflow.com/questions/952503/c-sharp-variable-initialization-question
                //int
                //int i = 0;
                //Console.WriteLine("{0}", i);
                //----------------------------------------------------------------------------------------
            }
        }
Esempio n. 3
0
        protected override void OnStart(string[] args)
        {
            System.Threading.Thread.Sleep(10000);
            //Windows svc start code:
            System.Diagnostics.Debugger.Launch();

            string[] myArgs = { "steveZOMBO" };
            //Main(args);
            base.OnStart(myArgs);

            //TODO: place your start code here
            FileSystemWriter.WriteSomething("started");
            Main(myArgs);
        }
Esempio n. 4
0
 private static void OnTimedEvent(Object source, ElapsedEventArgs e)
 {
     //Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime);
     FileSystemWriter.WriteSomething(string.Format("hello from program.cs - Main[] at {0}", e.SignalTime));
 }