winforms csharp code cross thread operation is not valid

Code Example - winforms csharp code cross thread operation is not valid

                
                        UserContrl1_LOadDataMethod()
{
    string name = "";
    if(textbox1.InvokeRequired)
    {
        textbox1.Invoke(new MethodInvoker(delegate {
          name = textbox1.text; 
        }));
    }
    if(name == "MyName")
    {
        // do whatever
    }
}