Save when exit

1. fix image cache
2. fix save when exit since destructor won't be called
3. fix #583 #582 (partially)  #581 (partially)  #580
This commit is contained in:
bao-qian
2016-05-02 22:37:01 +01:00
parent a7a34ac6b2
commit c6aff8424c
12 changed files with 65 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage;
namespace Wox.Infrastructure.Image
@@ -71,7 +72,7 @@ namespace Wox.Infrastructure.Image
public static void PreloadImages()
{
Stopwatch.Debug($"Preload {_cache.TopUsedImages.Count} images", () =>
Stopwatch.Debug("Preload images from cache", () =>
{
_cache.TopUsedImages.AsParallel().Where(i => !_imageSources.ContainsKey(i.Key)).ForAll(i =>
{
@@ -87,6 +88,7 @@ namespace Wox.Infrastructure.Image
}
});
});
Log.Info($"Preload {_cache.TopUsedImages.Count} images from cache");
}
public static ImageSource Load(string path, bool addToCache = true)

View File

@@ -0,0 +1,11 @@
namespace Wox.Infrastructure.Storage
{
/// <summary>
/// Save plugin settings/cache,
/// todo should be merged into a abstract class intead of seperate interface
/// </summary>
public interface ISavable
{
void Save();
}
}

View File

@@ -78,6 +78,7 @@
<Compile Include="Image\ImageCache.cs" />
<Compile Include="Image\ImageLoader.cs" />
<Compile Include="Logger\Log.cs" />
<Compile Include="Storage\ISavable.cs" />
<Compile Include="Storage\PluginSettingsStorage.cs" />
<Compile Include="Storage\Storage.cs" />
<Compile Include="Stopwatch.cs" />