feat(cancellation): exposes cancellation request (example in prime calculator)

This commit is contained in:
Dimitrie Stefanescu
2021-04-03 17:56:39 +01:00
parent b7e57b1ec8
commit 59f87b2a7d
3 changed files with 31 additions and 2 deletions
@@ -6,6 +6,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using GrasshopperAsyncComponent;
using System.Windows.Forms;
namespace GrasshopperAsyncComponentDemo.SampleImplementations
{
@@ -32,6 +33,15 @@ namespace GrasshopperAsyncComponentDemo.SampleImplementations
pManager.AddNumberParameter("Output", "O", "The n-th prime number.", GH_ParamAccess.item);
}
public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
base.AppendAdditionalMenuItems(menu);
Menu_AppendItem(menu, "Cancel", (s, e) =>
{
RequestCancellation();
});
}
}
public class PrimeCalculatorWorker : WorkerInstance