title: Calling methods from PCL to android - Xamarin
body: <p>How can I call method defined in my <code>PCL</code> project to <code>Android</code> project ? </p>
  
  <p>I have a method <code>DoWork()</code> defined in my PCL and I want this method to continuously be run in a service defined in my android project as follows:</p>
  
  <pre><code>public class BroadcastService : Service
  {
      IBinder mBinder;
  
  
      [return: GeneratedEnum]
      public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
      {
  
          Toast.MakeText(this, "BroadcastService is running ", ToastLength.Long).Show();
  
          Task.Run(() =&gt;
          {
              var counter = new Counter();
              counter.DoWork().Wait();
          });
  
          base.OnStartCommand(intent, flags, startId);
          return StartCommandResult.Sticky;
  
      }
  </code></pre>
  
  <p>The toast is appearing.
  However, the <code>DoWork()</code> is not running. Can someone enlighten what is wrong please?</p>
  
  <p>The full method signature for <code>DoWork()</code> :</p>
  
  <pre><code> private async void DoWork()
          {
         StartDetect();
  
              Device.StartTimer(TimeSpan.FromSeconds(20), () =&gt;
                  {
                      _foundTags = _truck.GetAvailableTrucks();
  
  
                      DoWork();
  
  
                  });
          }
  </code></pre>