I'm wanting to allow my plugin to have a check box on the widget. I want it to start when the checkbox is checked then stop when its unchecked. It works great when its checked it does what it suppose to do but when its unchecked it won't stop. Is there is way to cancel PlantItemsAsFarm or CollectItemsAtFarm? Here is the code I am using but I can't get it to stop once its started unless I turn the plugin off.
Code:
public void PluginRun() {
SetGroupStatus("Auto Farm", false);
while (true)
{
if (GetGroupStatus("Auto Farm"))
{
int laborPoints = me.laborPoints;
Random random = new Random();
var ms = random.Next(24, 107) * 1000;
var s = ms / 1000;
if (laborPoints > 2000)
{
CollectItemsAtFarm("Azalea", "Gathering: Spend 1 Labor to gather materials.", 32462);
PlantItemsAtFarm("Azalea Seed", 24553);
} else {
PlantItemsAtFarm("Azalea Seed", 43246);
Log("Labor under 2000, waiting to regen");
}
Thread.Sleep(ms);
} else {
CancelSkill(); <<<<<<<< Trying to cancel here but not working >>>>>>>>>
}
Thread.Sleep(50);
}
Thread.Sleep(50);
}