1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-03-04 02:38:18 +00:00
Radarr/NzbDrone/Providers/DebuggerProvider.cs

47 lines
1.1 KiB
C#
Raw Normal View History

2011-10-06 20:37:41 -07:00
using System;
using System.Diagnostics;
using System.Threading;
using NLog;
namespace NzbDrone.Providers
{
2011-11-25 18:06:40 -08:00
[DebuggerStepThroughAttribute]
2011-10-06 23:36:04 -07:00
public class DebuggerProvider
2011-10-06 20:37:41 -07:00
{
2012-02-10 16:48:20 -08:00
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2011-10-06 20:37:41 -07:00
2011-10-06 23:36:04 -07:00
public virtual void Attach()
2011-10-06 20:37:41 -07:00
{
#if DEBUG
if (Debugger.IsAttached)
{
Logger.Info("Trying to attach to debugger");
2011-10-06 23:57:43 -07:00
int count = 0;
2011-10-06 20:37:41 -07:00
while (true)
{
try
{
ProcessAttacher.Attach();
Logger.Info("Debugger Attached");
return;
}
catch (Exception e)
{
count++;
if (count > 20)
{
Logger.WarnException("Unable to attach to debugger", e);
return;
}
Thread.Sleep(100);
}
}
}
#endif
}
}
2011-10-06 23:57:43 -07:00
}