コード例 #1
0
        public override void Stop()
        {
            if (intent != null)
            {
                base.Stop();

                context.StopService(intent);
                context.UnregisterReceiver(receiver);

                receiver = null;
                intent   = null;
            }
        }
コード例 #2
0
        public override void Start(Func <Task> action, CancellationTokenSource cts, Action <ProgressMessage> onProgressCallback = null)
        {
            if (intent == null)
            {
                base.Start(action, cts, onProgressCallback);

                receiver = new BackgroundingReceiver(action, TokenSource.Token);
                intent   = new Intent(context, typeof(BackgroundingService));

                context.RegisterReceiver(receiver, new IntentFilter(Constants.IntentStartKey));

                context.StartService(intent);
            }
        }