title: NopCommerce Task Plugin not starting task
body: <p>Using NopCommerce 3.8.</p>
  
  <p>I have created a new Misc plugin.  The purpose is to run a task that restfully calls my web api for data.</p>
  
  <p>The following is my code:</p>
  
  <p><strong>Plugin class</strong> </p>
  
  <pre><code>public class MereSyncPlugin : BasePlugin, IMiscPlugin
  {
      private MereSyncObjectContext _context;
      private IScheduleTaskService _schedualTaskService;
  
      public MereSyncPlugin(MereSyncObjectContext context, IScheduleTaskService schedualTaskService)
      {
          _context = context;
          _schedualTaskService = schedualTaskService;
      }
  
      public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
      {
          actionName = "";
          controllerName = "";
          routeValues = new RouteValueDictionary()
          {
              { "Namespaces", "Nop.plugin.Misc.MereSync.Controllers" },
              { "area", null }
          };   
      }
  
      public override void Install()
      {
          //TODO: add more
          _schedualTaskService.InsertTask(new Nop.Core.Domain.Tasks.ScheduleTask()
          {
              Enabled = true,
              Name = "Product Sync",
              Seconds = 3600,
              StopOnError = false,
              Type = "Nop.Plugin.Misc.MereSync.ProductSyncTask, Nop.Plugin.Misc.MereSync"
          });
  
          //_context.Install();
          base.Install();
      }
  
      public override void Uninstall()
      {
          Nop.Core.Domain.Tasks.ScheduleTask task = _schedualTaskService.GetTaskByType("Nop.Plugin.Misc.MereSync.ProductSyncTask, Nop.Plugin.Misc.MereSync");
  
          if (task != null)
              _schedualTaskService.DeleteTask(task);
  
          //_context.Uninstall();
          base.Uninstall();
      }
  }
  </code></pre>
  
  <p><strong>Object context class (although not set up at this point so commented out some parts)</strong></p>
  
  <pre><code>public class MereSyncObjectContext : DbContext, IDbContext
  {
      public bool ProxyCreationEnabled
      {
          get
          {
              throw new NotImplementedException();
          }
  
          set
          {
              throw new NotImplementedException();
          }
      }
  
      public bool AutoDetectChangesEnabled
      {
          get
          {
              throw new NotImplementedException();
          }
  
          set
          {
              throw new NotImplementedException();
          }
      }
  
      public MereSyncObjectContext(string nameOrConnectionString) : base(nameOrConnectionString)
      {
  
      }
  
      /*protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          //TODO: insert ALL model MAPPINGS!!!!
          //modelBuilder.Configurations.Add(new insertnewmap());
          base.OnModelCreating(modelBuilder);
      }*/
  
      public string CreateDatabaseInstallationScript()
      {
          return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
      }
  
      public void Install()
      {
          Database.SetInitializer&lt;MereSyncObjectContext&gt;(null);
          Database.ExecuteSqlCommand(CreateDatabaseInstallationScript());
          SaveChanges();
      }
  
      public void Uninstall()
      {
          //this.DropPluginTable("MereSys_TableName");
      }
  
      IDbSet&lt;TEntity&gt; IDbContext.Set&lt;TEntity&gt;()
      {
          return base.Set&lt;TEntity&gt;();
      }
  
      public IList&lt;TEntity&gt; ExecuteStoredProcedureList&lt;TEntity&gt;(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
      {
          throw new NotImplementedException();
      }
  
      public IEnumerable&lt;TElement&gt; SqlQuery&lt;TElement&gt;(string sql, params object[] parameters)
      {
          throw new NotImplementedException();
      }
  
      public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = default(int?), params object[] parameters)
      {
          throw new NotImplementedException();
      }
  
      public void Detach(object entity)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p><strong>Task class</strong></p>
  
  <pre><code>public class ProductSyncTask : ITask
  {
      private readonly ILogger _logger;
      public ProductSyncTask(ILogger logger)
      {
          this._logger = logger;
      }
      public async void Execute()
      {
          //TODO: Call My method, USE BEST PRACTICE, IoC DI
          //throw new NotImplementedException();
          _logger.InsertLog(Nop.Core.Domain.Logging.LogLevel.Information, "Start", "Product sync has started");
          ProductSyncService test = new ProductSyncService();
          await test.GetProductsAsync();
      }
  }
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>When i Navigate in the Nopcommerce backend to the log file </p>
  
  <blockquote>
    <p>admin area > system > log</p>
  </blockquote>
  
  <p>I expected to see my log statment there, but nothing shows.</p>
  
  <p>So i also check the schedual status of the task, it never started.  Breakpoints are also set up on my task class in debug mode and is never hit.</p>
  
  <p>So, Am i missing something here? Is my implimentation correct?</p>
  
  <p><strong>Notes:</strong></p>
  
  <p>I have removed the async call but it did nothing (as its never reaching the class level).  Cleaned and rebuilt, set copy local false where applicable.
  The plugin is installed. Event viewer on machine doesnt show any warnings or errors relating to nopcommerce. "Run Now" button when pressed refreshs page but no indication task run, nor my class breakpoints hit in debug mode.</p>
  
  <p><strong>Source file</strong>
  <a href="http://www.filedropper.com/meresync_1" rel="nofollow noreferrer">Source</a></p>
  
  <p>plugin contains my code so far, most is redundant not used i.e rest client etc as im not ever getting to that stage of the flow.</p>