call back function inside onButton click
<p>I have a gui application that  passes a "Connect" callback function to an API function inside of a class library, I need to access that callback function inside of an event handler. Here is what I got so far:</p>

<p>Gui:</p>

<pre><code>    public bool ConnectI2CFn(int selected_index)
    {
        return true;
    }
    Interface.RegisterInterface(IFaceType.I2C, i2cCfg, I2COptions, ConnectI2CFn);
</code></pre>

<p>.DLL:</p>

<pre><code>    public void RegisterInterface(IFaceType iface, object iface_config, int options, Func&lt;int,bool&gt;Connect, Func&lt;int,bool&gt;Disconnect)
    {
        //Test
        if (Connect(cboAddress.SelectedIndex))
        {
            MessageBox.Show("Connect");
        }
        if (Disconnect(cboAddress.SelectedIndex))
        {
            MessageBox.Show("Disconnect");
        }

        switch (iface)
        {
            case IFaceType.I2C:
                I2CConfig i2cCfg = (I2CConfig)iface_config;                    
                i2cCfg.Type = IFaceType.I2C;
                cboInterface.Items.Add(i2cCfg.InterfaceName);
                CreateListOfInterfaces(i2cCfg,i2cCfg.Type); 

                break;

            case IFaceType.UART:
                UARTConfig uartCfg = (UARTConfig)iface_config;
                uartCfg.Type = IFaceType.UART;
                cboInterface.Items.Add(uartCfg.InterfaceName);
                CreateListOfInterfaces(uartCfg, uartCfg.Type);


                break;

            case IFaceType.DISEQC:
                DISEQCConfig diseqcCfg = (DISEQCConfig)iface_config;
                diseqcCfg.Type = IFaceType.DISEQC;
                cboInterface.Items.Add(diseqcCfg.InterfaceName);
                CreateListOfInterfaces(diseqcCfg, diseqcCfg.Type);



                break;

        }

        if(options == 1)
        {
            cboInterface.SelectedIndex = cboInterface.Items.Count - 1;
            ChangeInterface(iface, cboInterface.SelectedIndex);
        }
    }


    private void btnConnect_Click(object sender, EventArgs e)
    {

    } 
</code></pre>

<p>This is my first time writing call back functions, I am not sure if I did it right.</p>
