BackgroundTask every minute Windows Store App (C#)

2019-06-13 21:13发布

问题:

So after much searching through the internet and trial and errors I've constructed a backgroundTask in a W8 App. But apperently the windows BackgroundTask class does only allow you to have a interval of 15 minutes.

Though for the application I'm developing is this useless. I need a interval of max 1 minute. Does anyone know a working workaround for a background task to run with the app suspended in a max interval of 1 minute?

回答1:

Per the documentation (see here and here), there's no way to schedule it more frequently than every 15 minutes. Your question implies you already knew this, however.

I don't think there is going to be a workaround available, and even if you found one, I'm pretty sure that would be grounds for having your app rejected from the store.



回答2:

One theoretical approach you can take (I haven't tried this, and I haven't tried to research if it would work) is to have 15 separate background tasks, one for each minute.

Depending on how Windows handles launching background tasks, you can either try to schedule 15 separate tasks with 15 separate delays until they start, or 15 tasks that all run at once with differing Thread.Sleep() delays in them.



回答3:

If it is for personal use as your comments suggests, the app sound more like a desktop app.

But alternative you could do the app backend as a windows service or normal win32 app and then create a windows store app for nice frontend that gets its information over localhost http.