multitasking

When to call completionHandler in application:performFetchWithCompletionHandler: when Background Fetch is async?

我是研究僧i 提交于 2019-12-04 23:58:22
问题 I have an app that fetches content in the background with the help of Background Fetch. So if a Background Fetch should take place my application:performFetchWithCompletionHandler: method is called. In this method I use NSURLConnection to fetch content asynchronous. In my current implementation I only start the request and then call the completionHandler with UIBackgroundFetchResultNewData . I know that this cannot be right. So my question is, how do I correctly call the completionHandler

Understanding Async/Await pattern for multi-tasking

好久不见. 提交于 2019-12-04 22:07:45
Currently, i am having difficulties to understand multi-tasking using async and await pattern. In order test a case, i have written following code to understand some basics; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private int global_int = 10; public async Task<int> RunAsyncTask() { // This method runs asynchronously. await Task.Run(() => Calculate()); return global_int; } private int Calculate() { Console.WriteLine("Ticket count: " + --global_int); return global_int; } private async void Start_Button_Click(object sender, RoutedEventArgs e) {

iPhone sdk, Running app in background and send frequent http request

巧了我就是萌 提交于 2019-12-04 19:43:45
I am trying to take advantage of iPhone 4 multitasking feature. I want to run app in background and frequently send http request to send/receive data, is it possible? Surprisingly, there is actually very little time-slicing going on in the "multi-tasking" iOS 4.x. What goes on instead is really just application suspend / resume. When an application is sent to the background upon the user tapping the home button, it will stop getting execute cycles after a short while (*). (*) There are a few exceptions. Applications which declare themselves as "VoIP providers", location-based apps, and music

Programmatically refresh screenshot in iOS7 multitasking screen?

我只是一个虾纸丫 提交于 2019-12-04 18:49:07
I have a music player app which implements background audio. I’m trying to update the screenshot in the iOS7 multi-tasking switcher when the track changes. So, if I background the app during Song A, it finishes and Song B comes on, if I then go into the tray I’d like to see a screenshot showing Song B’s artwork, title, etc. I’ve done some digging and not managed to find any way to tell iOS to update short of implementing Background Fetch and going all out with that. Is there another means of doing this, something I can call to tell it to refresh it when my tracks change? Apple does not provide

Use of Standard location service for tracking traveled distance in a foreground/background app

孤者浪人 提交于 2019-12-04 16:51:43
I have to develop a kind of GPS navigation application that needs to constantly keep track of the position of the user, which is moving by car. In the specific, I don't have to display the current location on a map but just to record its position with the best possible precision in order to calculate the total distance traveled. Of course the application needs to continue its work in background if the user switch to another app, a phone call come in or something like that… From the tests I have made and from what I have learned from this useful post (and from the documentation ), it seems to

How to check if thread has finished work in C++11 and above?

左心房为你撑大大i 提交于 2019-12-04 09:55:58
How can I check if thread has finished work in C++11 and above? I have been reading the documentation and I have written the following code: #include <iostream> #include <thread> void mythread() { //do some stuff } int main() { std::thread foo(mythread); if (foo.joinable()) { foo.join(); //do some next stuff } } joinable tells only that the thread has started work, but I would like to know how to write code to check if the thread has finished work. For example: #include <iostream> #include <thread> void mythread() { //do some stuff } int main() { std::thread foo(mythread); if (foo.finishedWork

CPU Registers and Multitasking

心不动则不痛 提交于 2019-12-04 07:56:26
I'm currently learning Assembly and I'm confused how the CPU registers work with Multitasking. So in a Multitasking System. CPU can pause the execution of a certain program at any time and run another program. So how are the register values preserved during this step ? Are the registers pushed to stack or any other way ? osgx how the CPU registers work with Multitasking. CPU basically may not work with multitasking, task switch may be (and is) implemented in software. Some CPU (intel x86) may have hardware state (TSS https://en.wikipedia.org/wiki/Task_state_segment ) and TR (task register) to

iPhone OS 4.0.x - transition from background to foreground

丶灬走出姿态 提交于 2019-12-04 07:14:42
问题 iPhone programming question: Is it possible to wakeup/resume iPhone application from background mode to foreground mode programmatically? I have a long-running background task, which is being launched in applicationDidEnterBackground method of UIApplicationDelegate. I need to make my application active/visible using some code inside this background task. Is this possible? Thanks. 回答1: This is not possible. However, you can fire a local notification to alert the user. 来源: https://stackoverflow

How to resume AVAudioPlayer after interrupted in background

折月煮酒 提交于 2019-12-04 05:06:18
I am playing music using AVAudioPlayer in background. The problem is: if there is a incoming calling interrupts the player, it will never resume unless switch to foreground and do it manually. The code is simple, to play it in background: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil]; url = [[NSURL alloc] initFileURLWithPath:...]; audio_player = [[AVAudioPlayer alloc] initWithContentsOfURL: url error:NULL]; audio_player.delegate = self; bool ret = [audio_player play]; delegate to handle

Which methods are called when user presses home button and double presses it again to return

*爱你&永不变心* 提交于 2019-12-04 04:25:27
问题 I want to know which methods (events) are called when user presses home button and double presses it again to return to my app. 回答1: applicationDidEnterBackground applicationWillEnterForeground These all called in the app delegate All details can be found here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html 来源: https://stackoverflow.com/questions/5445792/which-methods-are-called-when-user-presses-home-button-and