Hello,
-
I’m currently disabling the plugin by setting
loopratehz = 0
.
I’m wondering if this is sufficient, or if I should completely unload the plugin to free up memory or other resources. -
The following code doesn’t seem to work as expected:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MissionPlanner.Utilities;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading.Tasks;
using MissionPlanner;
namespace test_unloading
{
public class test_unloading : MissionPlanner.Plugin.Plugin
{
public override string Name { get; }
public override string Version { get; }
public override string Author { get; }
private int loop_count = 0;
public override bool Init()
{
return true;
}
public override bool Loaded()
{
this.loopratehz = 1f;
return true;
}
public override bool Loop()
{
loop_count++;
Console.WriteLine($"Plugin Loop Count: {loop_count}");
if (loop_count >= 5)
{
this.loopratehz = 0;
Console.WriteLine("Unloading plugin after 5 loops.");
MissionPlanner.Plugin.PluginLoader.Plugins.Remove(this); // Triggers Exit()??
}
return true;
}
public override bool Exit()
{
Console.WriteLine("Plugin Unloaded.");
return true;
}
}
}
Any advice or clarification would be greatly appreciated.
Thank you!