Radeon Reset Bug fix service
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RadeonResetBugFix/RadeonResetBugFixService/MainHandler.cs

50 lines
1.4 KiB

namespace RadeonResetBugFixService
{
using System;
using System.IO;
using Contracts;
using Logging;
using Tasks;
class MainHandler
{
private string LogFilename { get; }
private DevicesStatus StartupDevicesStatus { get; } = new DevicesStatus();
private DevicesStatus ShutdownDevicesStatus { get; } = new DevicesStatus();
private readonly object Mutex = new object();
public MainHandler()
{
var date = DateTime.Now;
this.LogFilename = Path.Combine(
Constants.LogDirectory,
$"radeonfix_{date:yyyyMMdd}_{date:HHmmss}.log");
}
public void HandleEntryPoint(string name, Action<ILogger> handle)
{
using (var fileLogger = new FileLogger(this.LogFilename))
{
using (ILogger logger = new TaskLoggerWrapper(fileLogger, name))
{
logger.Log($"Build date: {EnvironmentHelper.GetServiceBuildDate()}");
try
{
lock (this.Mutex)
{
handle(logger);
}
}
catch (Exception e)
{
logger.LogError(e.ToString());
}
}
}
}
}
}