title: windows service (with timer) not working without console
body: <p>I make a windows service with Timers.Timer.
  If i run as console app works fine, but if I change setting as windows app and  I comment all Console functions, the timer not working. with Console.ReadLine(); all good. but I dont should open console.</p>
  
  <pre><code> protected override void OnStart(string[] args)
      {
          AutoLog = false;
          SetTimer();
          Console.ReadLine();//if remove this line dont works
      }
  </code></pre>
  
  <p>SetTimer()</p>
  
  <pre><code>private void SetTimer()
      {
          mytimer = new Timer();
          mytimer.Interval = 2000;
          mytimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
          mytimer.Enabled = true;
      }
  </code></pre>
  
  <p>OnTimedEvent()</p>
  
  <pre><code> private void OnTimedEvent(object source, ElapsedEventArgs e)
      {
          mytimer.Enabled = false;
          EventLog evento1 = new EventLog();
          evento1.Source = "scPublicar";
          evento1.Log = "Publicar";
          evento1.WriteEntry("Publicación corriendo,  OnTimedEvent");
          mytimer.Enabled = true;
      }
  </code></pre>
  
  <p>Program.cs Main()</p>
  
  <pre><code> static void Main(string[] args)
      {
          ServiceBase[] servicesToRun;
          servicesToRun = new ServiceBase[] { new Publicar() };
          if (Environment.UserInteractive)
          {
              MethodInfo onStartMethod = typeof(ServiceBase).GetMethod("OnStart", BindingFlags.Instance | BindingFlags.NonPublic);
              foreach (ServiceBase service in servicesToRun)
              {
                  onStartMethod.Invoke(service, new object[] { new string[] { } });
              }
          }
          else
              ServiceBase.Run(servicesToRun);
      }
  </code></pre>
  
  <p>Thanks for yours answers </p>