mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
More NzbDrone.exe refactoring
This commit is contained in:
parent
f3ca3e97f9
commit
69ba365cd3
11 changed files with 324 additions and 176 deletions
54
NzbDrone/Providers/DebuggerProvider.cs
Normal file
54
NzbDrone/Providers/DebuggerProvider.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Providers
|
||||
{
|
||||
internal class DebuggerProvider
|
||||
{
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetLogger("DebuggerProvider");
|
||||
|
||||
|
||||
internal virtual void Attach()
|
||||
{
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue