When I need to debug a windows service I usually make a call to Thread.Sleep and then attach the debugger manually.

   1:  protected override void OnStart(string[] args)
   2:  {
   3:   
   4:      Thread.Sleep(10000);
   5:   

 

But now I have realized that there is an easier solution to this problem and it is to launch the debugger by yourself!

   1:          protected override void OnStart(string[] args)
   2:          {
   3:   
   4:              #if DEBUG
   5:              if (Properties.Settings.Default.Debug)
   6:              {
   7:                  System.Diagnostics.Debugger.Launch();
   8:              }
   9:              #endif

相关文章:

  • 2021-07-27
  • 2021-05-15
  • 2022-01-25
  • 2021-06-20
  • 2022-01-14
  • 2021-08-24
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-08-07
  • 2021-08-07
  • 2021-04-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
相关资源
相似解决方案