How to use System.Action<> correctly
<p>I am currently converting a Windows Forms application into a Console application in C#.</p>

<p>I am busy converting the code and I am having problems with some of the syntax which I am unsure of how to correctly convert.
Here is the original code in the windows forms app:</p>

<pre><code>    private eSkan.api.TeSkanAPI feSkanAPI = null;

    private void MessageFilter_AddRemove_Invoked(bool AddFilter, IMessageFilter Filter)
    {
        if (AddFilter)
        { 
            Application.AddMessageFilter(Filter); 
        }
        else 
        { 
            Application.RemoveMessageFilter(Filter); 
        }
    }
    private void MessageFilter_AddRemove(bool AddFilter, IMessageFilter Filter)
    {
        {
            IAsyncResult sr = BeginInvoke((ESKAN_ADD_REMOVE_MESSAGEFILTER)MessageFilter_AddRemove_Invoked,
                                          AddFilter, Filter);
            sr.AsyncWaitHandle.WaitOne(2000);
        }
    }

    private void IniteSkan()
    {
        lMSG.Items.Clear();
        feSkanAPI = new TeSkanAPI();
        // To add a message filter you have to add it from the MAIN thread - thus the main form
        feSkanAPI.AddRemoveMessageFilterProc = MessageFilter_AddRemove;
        feSkanAPI.OneSkanEvent += eScan_Callback;
        feSkanAPI.Thread_Start(true);
    }

    public Form1()
    {
        InitializeComponent();

    }


    private void eScan_Callback_safe(EeSkan_EventType command, object Data)
    {

        lMSG.Items.Insert(0, "++++++++");
        lMSG.Items.Insert(0, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
        lMSG.Items.Insert(0, "New Command "+command.ToString());

        if (Data is TeSkan_EventInfo)
        {
            lMSG.Items.Insert(0, "Data File : " + ((TeSkan_EventInfo)Data).DataFile);
            lMSG.Items.Insert(0, "Image File : " + ((TeSkan_EventInfo)Data).ImageFile);
        } else if (Data is string)
        {
            lMSG.Items.Insert(0, "Data String : " + (string) Data); 
        }

        //lMSG.Items.Insert(0, "Image File " + ScanInfo.ImageFile);
        //lMSG.Items.Insert(0, "Data File " + ScanInfo.ImageFile);
        lMSG.Items.Insert(0, "--------");
    }

    /// &lt;summary&gt;
    /// When accesing GUI/Form/Components - you cannot work cross-thread.
    /// This method will invoke eScan_Callback_safe in main/GUI thread if another thread called it, 
    /// or call eScan_Callback_safe directly if already on GUI/main thread
    /// 
    /// &lt;/summary&gt;
    /// &lt;param name="ScanInfo"&gt;&lt;/param&gt;
    private void eScan_Callback(EeSkan_EventType command, object Data)
    {


        if (InvokeRequired)
        {
            this.Invoke((ESKAN_EVENT_CALLBACK)eScan_Callback_safe, command, Data);
        }
        else
        {
            eScan_Callback_safe(command, Data);
        }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        feSkanAPI.Thread_Stop(10000);
        feSkanAPI.Dispose();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        IniteSkan();
    }
</code></pre>

<p>I am using Action to do the BeginInvoke part in the console application. And I would like to know what would be the best to use for "InvokeRequired" part in the "eScan_Callback()" function.</p>
