locked
Is it possible to prevent suspended app from being killed by WinRT? RRS feed

  • Question

  • I am working on a server-like app(to cache the data retrieved from a remote WCF server) on WinRT and we know WinRT will kill suspended apps automatically when system memory resources is low.

    My question is: is there a way to keep an app alive when suspended?  




    Thursday, October 10, 2013 3:43 PM

Answers

All replies

  • Hi Silverbird,

    afaik there's no way to force that. But you should store your cached data in the OnSuspending-EventHandler in the App.xaml.cs-file. If it was terminated, you can restore that data. So you don't care if it is terminated or not.

    Did you read that already:

    Suspending Guidelines

    How to suspend an app (C#/VB/C++)
    How to resume an app (C#/VB/C++)


    Thomas Claudius Huber

    "If you can´t make your app run faster, make it at least look & feel extremly fast"

    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    • Proposed as answer by Dave SmitsMVP Thursday, October 10, 2013 6:09 PM
    • Marked as answer by silverbird.lee Saturday, October 12, 2013 10:16 AM
    Thursday, October 10, 2013 5:06 PM
  • like thomas said you cant keep your app alive but maybe you can work with streamsockets with the special background tasks for it?. what is your app really dooing? why need to cache the whole time? cant change that design?
    Thursday, October 10, 2013 6:09 PM
  • Hi Silverbird,

    afaik there's no way to force that. But you should store your cached data in the OnSuspending-EventHandler in the App.xaml.cs-file. If it was terminated, you can restore that data. So you don't care if it is terminated or not.

    Did you read that already:

    Suspending Guidelines

    How to suspend an app (C#/VB/C++)
    How to resume an app (C#/VB/C++)



    Hi, thanks for the quick answer. I know this callback, but my app will cache lots of data by design, and these data are deep hierarchical data, so there would be a lot of overhead to persist/reload them frequently. 
    Friday, October 11, 2013 12:50 AM
  • like thomas said you cant keep your app alive but maybe you can work with streamsockets with the special background tasks for it?. what is your app really dooing? why need to cache the whole time? cant change that design?

    Hi, Dave, my app is a rich client app which need to retrieve lots of hierarchical data from a remote WCF server. By design, the app will cache all the retrieved data so as to it can reuse them in the future and reduce the frequency/overhead of chatting with the server. I don't need to persist them in local disk, it would be enough to just keep them in memory. 

    Yes, I can change the design, not cache so many data, but if it would be better if there is a way to get it work. Your suggestion of making the app as background task sounds good. I'll try it and hope I am lucky.

    Friday, October 11, 2013 1:02 AM