❔ c# wpf textbox access violation

Hello does anyone know how can i edit the TextBox1.Text within the Task.run so i don't have an access violation ? here is the code :
private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Socket Server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                Server.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 80));
                Server.Listen(2);

                Socket Client;

                await Task.Run(() =>
                {
                    Client = Server.Accept();
                    TextBox1.Text = "Hello";
                    
                });
            }

            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex);
            }
        }
Was this page helpful?