sonarr-repo-only/NzbDrone/Providers/DebuggerProvider.cs

52 lines
1.1 KiB
C#
Raw Normal View History

2011-10-07 03:37:41 +00:00
using System;
using System.Diagnostics;
using System.Threading;
using NLog;
namespace NzbDrone.Providers
{
2011-10-07 06:36:04 +00:00
public class DebuggerProvider
2011-10-07 03:37:41 +00:00
{
private static readonly Logger Logger = LogManager.GetLogger("DebuggerProvider");
2011-10-07 06:36:04 +00:00
public virtual void Attach()
2011-10-07 03:37:41 +00:00
{
#if DEBUG
if (Debugger.IsAttached)
{
Logger.Info("Trying to attach to debugger");
var count = 0;
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
}
}
}