catch exception when dump position history xml

This commit is contained in:
Kang Yu 2024-08-27 19:32:13 -07:00
parent 7fd80af8bf
commit 1ef5e99d40
2 changed files with 14 additions and 12 deletions

View file

@ -215,11 +215,8 @@ namespace PersistentWindows.Common
File.WriteAllText(Path.Combine(appDataFolder, snapshotTimeFile), xml2, Encoding.Unicode); File.WriteAllText(Path.Combine(appDataFolder, snapshotTimeFile), xml2, Encoding.Unicode);
} }
public void WriteDataDump() private void WriteDataDumpCore()
{ {
if (!dumpDataWhenExit)
return;
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>)); DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
using (XmlWriter xw = XmlWriter.Create(sb)) using (XmlWriter xw = XmlWriter.Create(sb))
@ -231,6 +228,18 @@ namespace PersistentWindows.Common
DumpSnapshotTakenTime(); DumpSnapshotTakenTime();
} }
public void WriteDataDump()
{
try
{
if (dumpDataWhenExit)
WriteDataDumpCore();
}
catch (Exception e)
{
Log.Error(e.ToString());
}
}
private void ReadDataDump() private void ReadDataDump()
{ {

View file

@ -811,15 +811,8 @@ namespace PersistentWindows.SystrayShell
} }
public static void WriteDataDump() public static void WriteDataDump()
{
try
{ {
pwp.WriteDataDump(); pwp.WriteDataDump();
} }
catch (Exception e)
{
Log.Error(e.ToString());
}
}
} }
} }