Files
flowframes/Code/Program.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2020-11-23 16:51:05 +01:00
using Flowframes.Data;
using Flowframes.IO;
using Flowframes.OS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Flowframes
{
static class Program
{
public static Form1 mainForm;
public static bool busy = false;
public static string lastInputPath;
public static bool lastInputPathIsSsd;
2020-12-17 11:32:45 +01:00
public static Queue<InterpSettings> batchQueue = new Queue<InterpSettings>();
2020-11-23 16:51:05 +01:00
[STAThread]
static void Main()
{
Config.Init();
2020-11-27 09:45:06 +01:00
if (Config.GetBool("delLogsOnStartup"))
IOUtils.DeleteContentsOfDir(Paths.GetLogPath()); // Clear out older logs from previous session
2020-11-23 16:51:05 +01:00
Networks.Init();
2021-03-09 19:20:47 +01:00
Task.Run(() => DiskSpaceCheckLoop());
2020-11-23 16:51:05 +01:00
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainForm = new Form1();
Application.Run(mainForm);
2021-03-09 19:20:47 +01:00
}
static async Task DiskSpaceCheckLoop ()
{
while (true)
{
if (busy)
{
string drivePath = Interpolate.current.tempFolder.Substring(0, 2);
long mb = IOUtils.GetDiskSpace(Interpolate.current.tempFolder);
Logger.Log($"Disk space check for '{drivePath}/': {(mb / 1024f).ToString("0.0")} GB free.", true);
2021-03-09 19:20:47 +01:00
if (!Interpolate.canceled && mb < (Config.GetInt("minDiskSpaceGb", 6) * 1024))
2021-03-09 19:20:47 +01:00
Interpolate.Cancel("Running out of disk space!");
}
2020-11-23 16:51:05 +01:00
2021-03-09 19:20:47 +01:00
await Task.Delay(15000);
}
2020-11-23 16:51:05 +01:00
}
}
}