public override bool OnStartJob(JobParameters tloparams) { Task.Run(() => { Console.WriteLine("1hhhh"); w.Czywyslc(); Log.Debug("moje zadanie w tle", "to działa...chyba"); Console.WriteLine("2hhhh"); }); return(true); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { var notification = new Notification(Resource.Drawable.icon, "Service running in the foreground!"); var notificationIntent = new Intent(this, typeof(MainActivity)); var pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, 0); notification.SetLatestEventInfo(this, "Foreground Service", "Tap to to to App", pendingIntent); Log.Info(TAG, "OnStartCommand: The service is starting."); StartForeground((int)NotificationFlags.ForegroundService, notification); Task.Run(() => { for (int i = 1; i < 999; i++) { Wysylka w = new Wysylka(); w.Czywyslc(); Thread.Sleep(3600000); if (!this.cts.IsCancellationRequested) { this.StopSelf(); } i--; } }); return(StartCommandResult.Sticky); }