mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 17:27:59 +00:00
46 lines
No EOL
1.1 KiB
C#
46 lines
No EOL
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Threading;
|
|
using NLog;
|
|
|
|
namespace NzbDrone.Providers
|
|
{
|
|
public class DebuggerProvider
|
|
{
|
|
private static readonly Logger Logger = LogManager.GetLogger("Host.DebuggerProvider");
|
|
|
|
|
|
public virtual void Attach()
|
|
{
|
|
#if DEBUG
|
|
if (Debugger.IsAttached)
|
|
{
|
|
Logger.Info("Trying to attach to debugger");
|
|
|
|
int 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
|
|
}
|
|
}
|
|
} |