title: Windows service .Net core 3.1 not working after installing
body: <p>I'm creating a windows service .net core 3.1 write log, I done it and run in debug and release mode ok but when I install it and start it in services.msc, the service is not working. Here is my code in worker.cs. Can someone help me? sorry for my bad English.</p>
  
  <pre><code>public class Worker : BackgroundService
  {
  
      private readonly ILogger&lt;Worker&gt; _logger;
  
      public Worker(ILogger&lt;Worker&gt; logger)
      {
          _logger = logger;
      }
  
      protected override async Task ExecuteAsync(CancellationToken stoppingToken)
      {
          try
          {
              while (!stoppingToken.IsCancellationRequested)
              {
                  //When a mouse button is pressed
                  Hook.GlobalEvents().MouseDown += Program_MouseDown;
  
                  Application.Run(new ApplicationContext());
  
                  _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
  
                  Thread updatedb = new Thread(UpdateDB);
                  updatedb.Start();
  
                  await Task.Delay(1000, stoppingToken);
              }
          }
          catch (Exception e)
          {
  
              SaveMessage(e.ToString());
          }
  
      }
  }
  </code></pre>