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

66 lines
1.9 KiB

namespace RadeonResetBugFixService
{
using System;
using System.IO;
using System.Reflection;
using Contracts;
using Logging;
using Tasks;
class MainHandler
{
private string LogFilename { get; }
private object Mutex = new object();
public MainHandler()
{
var date = DateTime.Now;
this.LogFilename = Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"logs",
$"radeonfix_{date:yyyyMMdd}_{date:HHmmss}.log");
}
public void HandleStartup()
{
using (var fileLogger = new FileLogger(this.LogFilename))
{
using (ILogger logger = new TaskLoggerWrapper(fileLogger, "Startup"))
{
lock (this.Mutex)
{
TasksProcessor.ProcessTasks(
logger,
new ITask[]
{
new DisableVirtualVideoTask(),
new EnableAmdVideoTask(),
});
}
}
}
}
public void HandleShutdown()
{
using (var fileLogger = new FileLogger(this.LogFilename))
{
using (ILogger logger = new TaskLoggerWrapper(fileLogger, "Shutdown"))
{
lock (this.Mutex)
{
TasksProcessor.ProcessTasks(
logger,
new ITask[]
{
new StopAudioServiceTask(),
new DisableAmdVideoTask(),
new EnableVirtualVideoTask(),
});
}
}
}
}
}
}