C# first class continuation via C++ interop or some other way?

There is the C# 5 CTP, which performs a continuation-passing-style transformation over methods declared with the new async keyword, and continuation-passing based calls when using the await keyword. This is not actually a new CLR feature but rather a set of directives for the compiler to perform the CPS transformation over your code and a … Read more

How to create a thread/Task with a continuous loop?

Something like this would work: var cancellationTokenSource = new CancellationTokenSource(); var task = Repeat.Interval( TimeSpan.FromSeconds(15), () => CheckDatabaseForNewReports(), cancellationTokenSource.Token); The Repeat class looks like this: internal static class Repeat { public static Task Interval( TimeSpan pollInterval, Action action, CancellationToken token) { // We don’t use Observable.Interval: // If we block, the values start bunching up … Read more

What does it mean to say “linux kernel is preemptive”?

Prior to Linux kernel version 2.5.4, Linux Kernel was not preemptive which means a process running in kernel mode cannot be moved out of processor until it itself leaves the processor or it starts waiting for some input output operation to get complete. Generally a process in user mode can enter into kernel mode using … Read more

How to do multithreading, concurrency or parallelism in iOS Swift?

Or you can use operation queues, too. In Swift 3: let queue = OperationQueue() queue.addOperation() { // do something in the background OperationQueue.main.addOperation() { // when done, update your UI and/or model on the main queue } } Either this, or GCD, which Andy illustrated, work fine. See Apple’s Concurrency Programming Guide for the relative … Read more

Prevent iOS from taking screen capture of app before going into background

You are on the right track. This is Apple’s recommended way to do this as noted in the iOS Application Programming Guide: Remove sensitive information from views before moving to the background. When an application transitions to the background, the system takes a snapshot of the application’s main window, which it then presents briefly when … Read more

multiple parallel async calls with await

The async/await includes a few operators to help with parallel composition, such as WhenAll and WhenAny. var taskA = someCall(); // Note: no await var taskB = anotherCall(); // Note: no await // Wait for both tasks to complete. await Task.WhenAll(taskA, taskB); // Retrieve the results. var resultA = taskA.Result; var resultB = taskB.Result;

Use of background/foreground methods in AppDelegate

Each object receive a UIApplicationDidEnterBackgroundNotification notification when the app goes in background. So to run some code when the app goes in background, you just have to listen to that notification where you want : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appHasGoneInBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; Don’t forget to release the listener when you don’t need to listen to it … Read more

Detecting user settings for Background App Refresh in iOS 7

this is what you are looking for. if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) { NSLog(@”Background updates are available for the app.”); }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied) { NSLog(@”The user explicitly disabled background behavior for this app or for the whole system.”); }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted) { NSLog(@”Background updates are unavailable and the … Read more