MapInfo Pro Developers User Group

 View Only
  • 1.  Adding background tasks

    Posted 08-02-2022 10:01
    Hi!

    I've been unable to find documentation on how to add a MapInfo Pro background task via the .NET API.

    The type IMapInfoApplication has a collection of BackgroundTasks.
    So, if MIApp is an instance that implements that interface, I can do:

    MIApp.BackgroundTasks.AddTask(task);

    However, how do I even create a task? AddTask wants an ITask but this is merely the interface and I don't know how to construct a task, or what they are exactly (a sequence of MapBasic statements??)

    ------------------------------
    Jonas Nordlund
    Software Developer
    Norconsult AB
    Sweden
    ------------------------------


  • 2.  RE: Adding background tasks

    Employee
    Posted 08-03-2022 03:05
    Hi Jonas

    In the Samples folder in the MapBasic installation folder, there are a couple of examples.

    There's a Python example in gdalDataImport.py on how to execute a GDAL Import process as a task.

    And there is a .NET example in DotNet\ProSampleAddIn. Check the EventLogExporter.

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Adding background tasks

    Posted 08-03-2022 10:15
    Thank you, I didn't look close enough because I disregarded RibbonInterface but I see there are many samples I missed there. I'll have a look!

    ------------------------------
    Jonas Nordlund
    Software Developer
    Norconsult AB
    Sweden
    ------------------------------



  • 4.  RE: Adding background tasks

    Employee
    Posted 08-04-2022 00:40
    Edited by Anshul Goel 08-04-2022 00:40
    Hi Jonas,

    Apart from the EventLogExporter.cs file, We have also created a new TaskBase class in MapInfo.AddIns.Common assembly which encapsulates lots of functionality that you see in EventLogExporter.cs

    We have also added TaskMessage, TaskCommand classes within the same assembly as you see in EventLogExporter.cs file. Take a look at sample below, for more information you can refer to EventLogExporter.cs file.

    public class NewBGTask : TaskBase
    	{
    		public override void worker_DoWork(object sender, DoWorkEventArgs e)
    		{
    			throw new NotImplementedException();
    		}
    
    		protected override void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    		{
    			base.worker_RunWorkerCompleted(sender, e);
    		}
    	}​


    ------------------------------
    Anshul Goel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------