Пример #1
0
        void StartBgActivity()
        {
            var activity = new NSBackgroundActivityScheduler("com.emclient.FormsTest.TestActivity");

            activity.Repeats  = true;
            activity.Interval = 1;
            activity.Schedule((completionHandler) => {
                Console.WriteLine("Background activity!");
                //completionHandler(NSNumber.FromInt32(1));
            });
        }
Пример #2
0
        void ToggleBgActivity()
        {
            if (activity != null)
            {
                Console.WriteLine($"Invalidating background activity");
                activity.Invalidate();
                activity = null;
                return;
            }

            Console.WriteLine($"Scheduling background activity");
            activity = new NSBackgroundActivityScheduler("com.emclient.FormsTest.BgActivity");
            activity.QualityOfService = NSBackgroundActivityScheduler.QoS.Utility;
            activity.Interval         = 2.0;
            activity.Repeats          = true;

            activity.Schedule((completion) => {
                Console.WriteLine($"Background activity - round:{counter}!");
                counter = (counter + 1) % round;
                completion(counter == 0 ? NSBackgroundActivityScheduler.Result.Finished : NSBackgroundActivityScheduler.Result.Deferred);
            });
        }