SHARE
TWEET

Untitled

a guest Mar 20th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Nuget: Xamarin.Android.Arch.Work.Runtime
  2.  
  3. var r = PeriodicWorkRequest.Builder.From<MyWorker>(TimeSpan.FromSeconds(5))
  4.     .SetConstraints(new Constraints.Builder()
  5.         .SetRequiresCharging(true)
  6.         .SetRequiredNetworkType(NetworkType.Unmetered)
  7.         .Build())
  8.     .Build();
  9.  
  10. WorkManager.Instance.Enqueue(r);
  11.  
  12. // ****************************************
  13.  
  14. public class MyWorker : Worker
  15. {
  16.     public MyWorker(Context context, WorkerParameters workerParameters)
  17.         : base(context, workerParameters)
  18.     {
  19.     }
  20.  
  21.     public override Result DoWork()
  22.     {
  23.         Android.Util.Log.Debug("XAMARIN", "Work Request!");
  24.         return new Result.Success();
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top