invalidoperationexception c# ui thread

C#
this.Invoke(new Action(() =>
            {
                // UI operation here
            }));
Source

Also in C#: