title: Backgrounded jobs not working with Shiny library in a simple Xamarin Forms project
body: <p>I am trying to implement the very promising Shiny library (for background jobs) from Allan Ritchie.  I have only tried this in a simple File/New Project for Android thus far (haven't implemented the code for iOS or UWP), but I am not able to get it to run.</p>
  
  <p>I am following the article <a href="https://allancritchie.net/posts/shinyjobs" rel="nofollow noreferrer">https://allancritchie.net/posts/shinyjobs</a>.  However, when I run I get the following exception...</p>
  
  <p><a href="https://i.stack.imgur.com/tQFie.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tQFie.png" alt="enter image description here"></a></p>
  
  <p>And I never hit this breakpoint...</p>
  
  <p><a href="https://i.stack.imgur.com/tfvrx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tfvrx.png" alt="enter image description here"></a></p>
  
  <p>My code can be cloned from <a href="https://github.com/JohnLivermore/SampleXamarinApp.git" rel="nofollow noreferrer">https://github.com/JohnLivermore/SampleXamarinApp.git</a></p>
  
  <p>But here it is inline as well...</p>
  
  <p><strong>App.xaml.cs</strong></p>
  
  <pre><code>public partial class App : Application
  {
      public App()
      {
          InitializeComponent();
  
          MainPage = new MainPage();
      }
  
      protected override async void OnStart()
      {
          var job = new JobInfo
          {
              Identifier = "YourFirstJob",
              Type = typeof(YourFirstJob),
  
              // these are criteria that must be met in order for your job to run
              BatteryNotLow = false,
              DeviceCharging = false,
              RequiredInternetAccess = InternetAccess.Any,
              Repeat = true //defaults to true, set to false to run once OR set it inside a job to cancel further execution
          };
  
          // lastly, schedule it to go - don't worry about scheduling something more than once, we just update if your job name matches an existing one
          await ShinyHost.Resolve&lt;Shiny.Jobs.IJobManager&gt;().Schedule(job);
      }
  
      protected override void OnSleep()
      {
      }
  
      protected override void OnResume()
      {
      }
  }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>public class Startup : ShinyStartup
  {
      public override void ConfigureServices(IServiceCollection services)
      {
      }
  }
  </code></pre>
  
  <p><strong>YourFirstJob.cs</strong></p>
  
  <pre><code>public class YourFirstJob : IJob
  {
      public YourFirstJob()
      {
      }
  
      public async Task&lt;bool&gt; Run(JobInfo jobInfo, CancellationToken cancelToken)
      {
          //await this.dependency.SomeAsyncMethod(id);
  
          return true; // this is for iOS - try not to lie about this - return true when you actually do receive new data from the remote method
      }
  }
  </code></pre>
  
  <p><strong>MainActivity.cs</strong></p>
  
  <pre><code>[Activity(Label = "SampleApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
  public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  {
      protected override void OnCreate(Bundle savedInstanceState)
      {
          TabLayoutResource = Resource.Layout.Tabbar;
          ToolbarResource = Resource.Layout.Toolbar;
  
          base.OnCreate(savedInstanceState);
  
          Xamarin.Essentials.Platform.Init(this, savedInstanceState);
          global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
          LoadApplication(new App());
      }
      public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
      {
          Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
          Shiny.AndroidShinyHost.OnRequestPermissionsResult(requestCode, permissions, grantResults);
  
          base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
      }
  }
  </code></pre>
  
  <p><strong>MainApplication.cs</strong></p>
  
  <pre><code>[Application]
  public class MainApplication : Application
  {
      public override void OnCreate()
      {
          base.OnCreate();
          Shiny.AndroidShinyHost.Init(this, new SampleApp.Startup());
      }
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>