Skip to content

Commit

Permalink
Add persistance saving handler
Browse files Browse the repository at this point in the history
  • Loading branch information
fahminlb33 committed Jun 11, 2020
1 parent 7731f42 commit e205b9d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/KFmaintenance/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Forms;
using Castle.Windsor;
using KFlearning.Core;
using KFlearning.Core.Services;
using KFmaintenance.Properties;
using KFmaintenance.Services;
using KFmaintenance.Views;
Expand Down Expand Up @@ -41,6 +42,9 @@ static void Main()
// enable TLS;
Helpers.EnableTls();

// app exit handler
Application.ApplicationExit += Application_ApplicationExit;

// bootstrap
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Expand All @@ -53,5 +57,22 @@ static void Main()
}
}
}

private static void Application_ApplicationExit(object sender, EventArgs e)
{
try
{
foreach (var usesPersistance in Container.ResolveAll<IUsesPersistance>())
{
usesPersistance.Save();
}
}
catch
{
// ignore
}

Container.Dispose();
}
}
}

0 comments on commit e205b9d

Please sign in to comment.