attraper des exceptions d'un autre thread

J'ai une méthode qui s'exécute dans un thread séparé. Le thread est créé et a commencé à partir d'un formulaire dans une application windows. Si une exception est levée à partir de l'intérieur du fil, ce qui est le meilleur moyen de passer à l'application principale. Maintenant, je suis de passage d'une référence à la forme principale dans le fil, puis l'invocation de la méthode du fil, et entraînant la méthode appelée par le thread principal de l'application. Est-il une meilleure pratique de la façon de le faire parce que je ne suis pas à l'aise avec la façon dont je le fais maintenant.

Exemple de mon formulaire:

public class frmMyForm : System.Windows.Forms.Form
{
    ///<summary>
    ///Create a thread
    ///</summary>
    ///<param name="sender"></param>
    ///<param name="e"></param>
    private void btnTest_Click(object sender, EventArgs e)
    {
        try
        {
            //Create and start the thread
           ThreadExample pThreadExample = new ThreadExample(this);
           pThreadExample.Start();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, Application.ProductName);
        }
    }

    ///<summary>
    ///Called from inside the thread 
    ///</summary>
    ///<param name="ex"></param>
    public void HandleError(Exception ex)
    {
        //Invoke a method in the GUI's main thread
        this.Invoke(new ThreadExample.delThreadSafeTriggerScript(HandleError), new Object[] { ex });
    }

    private void __HandleError(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Exemple de ma classe thread:

public class ThreadExample
{
    public delegate void delThreadSafeHandleException(System.Exception ex);

    private Thread thExample_m;

    frmMyForm pForm_m;
    private frmMyForm Form
    {
        get
        {
            return pForm_m;
        }
    }

    public ThreadExample(frmMyForm pForm)
    {
        pForm_m = pForm;

        thExample_m = new Thread(new ThreadStart(Main));
        thExample_m.Name = "Example Thread";
    }

    public void Start()
    {
        thExample_m.Start();
    }

    private void Main()
    {
        try
        {
            throw new Exception("Test");
        }
        catch (Exception ex)
        {
            Form.HandleException(ex);
        }
    }
}

source d'informationauteur Jeremy