Add activate statistics

This commit is contained in:
qianlifeng
2015-01-23 21:52:46 +08:00
parent 42d86fab8e
commit 4379145231
15 changed files with 83 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
namespace Wox.Infrastructure.Storage
@@ -12,6 +13,7 @@ namespace Wox.Infrastructure.Storage
/// </summary>
public abstract class JsonStrorage<T> : BaseStorage<T> where T : class, IStorage, new()
{
private static object syncObject = new object();
protected override string FileSuffix
{
get { return ".json"; }
@@ -39,8 +41,14 @@ namespace Wox.Infrastructure.Storage
protected override void SaveInternal()
{
string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
File.WriteAllText(ConfigPath, json);
ThreadPool.QueueUserWorkItem(o =>
{
lock (syncObject)
{
string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
File.WriteAllText(ConfigPath, json);
}
});
}
}
}