F # is a CLR language such that C # or VB. This means that it can reference CLR assemblies (both DLLs and EXEs), import public classes from them, and call public methods and properties. If the class, method or property is not publicly available, you can still access them using reflection, but you have little to do.
Note that for WinForm interface elements to respond to user actions, you need to start the Windows message loop (using Application.Run ). In the case of the F # shell, it seems they run it in the background thread and send actions to this thread using Control.Invoke or its equivalents ( WindowsFormsSynchronizationContext ).
To call the method that you showed in the example, you need to do one of the following:
1) if the btShowNextNumber_Click method is public:
form.Invoke(new Action(()=> form.btShowNextNumber_Click(form, EventArgs.Empty)));
or
SynchronizationContext.Current.Send(o => form.btShowNextNumber_Click(form, EventArgs.Empty));
2) if the btShowNextNumber_Click method btShowNextNumber_Click not public, but Button btShowNextNumber :
form.Invoke(new Action(()=> form.btShowNextNumber.PerformClick());
or
SynchronizationContext.Current.Send(o => form.btShowNextNumber.PerformClick());
As far as I understand how the F # shell works, you can configure the mail commands that you publish through SynchronizationContext.Send transparently, just like the IronPython shell does . I can’t say exactly how it works now. Need to check
source share