0

I have a PeriodicTask that updates a tile for my phone app and saves the information to persisted storage.

This works fine until the list gets to around a size of 11 or 12.

The objects that I save is a poco object with about 5 members. I basiclly get data, save data and create tile (not shown).

so

//get data
var newData = GetPocoFromWeb();
base.Add(newData); 

the base class

     public abstract class DataFetcher<T> where T : IDataCarrier, new()
        {
            protected readonly IPersist<List<T>> Persist;
            protected DataFetcher(IPersist<List<T>> persist)
            {
                Persist = persist;
            }

            protected void Add(T item)
            {
                var items = Persist.Load();
                items.Add(item);
                Persist.Save(items);
            }
        }

The persist class

public class Persist<T> : IPersist<T>
    {
        private readonly string _identifier;

        public Persist(string identifier)
        {
            _identifier = identifier;
        }

        public virtual T Load()
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(_identifier))
            {
                return (T)IsolatedStorageSettings.ApplicationSettings[_identifier];
            }

            return default(T);
        }

        public virtual void Save(T item)
        {
            IsolatedStorageSettings.ApplicationSettings[_identifier] = item;
            IsolatedStorageSettings.ApplicationSettings.Save();
        }  

    }

Am I perhaps using wrong storage? 11 items in a list isn't really that many.

Update: When I load the list and add to it using the application (not through the periodicTask) i can easily save several hundred items.

I don't get any error when running in emulator, it just works till the list has around 11 items and then stops working.

4

2 回答 2

1

您不会详细了解您遇到的错误(如果有的话),因此很难说。

说了这么多,想到以下几点:

  • 如果您NotifyComplete()在异步调用完成之前调用,您可能会在有机会之前被关闭。
  • 后台任务只有 6mb 内存(WP8 上 12mb)。如果你超过它,你的过程将被终止
  • 后台任务只有 25 秒左右的时间来执行。如果您继续过去,您的进程将被终止。
  • 不要使用IsolatedStorageSettings类在进程之间共享状态
  • 您应该使用 aMutex来保护进程对存储的访问。
于 2013-10-10T11:12:25.390 回答
0

您遇到的具体问题是什么?使用 IsolatedStorageSettings 不应限制您能够保留的列表的大小。

于 2013-10-10T10:42:46.270 回答