Writing in TextBox freezes the form

0

I have a form that has a TextBox and would like to write to it but give a typewriter effect so that the text is not added "dry" completely.

I've created a method that gets the text I'd like to add and does the effect as expected. However, the form is frozen and only after writing the entire text is it possible to use the form.

    private void escreverMensagem(string msg)
    {
        char[] msg_array = msg.ToArray<char>();

        for (int i = 0; i < msg_array.Length; i++)
        {
            txtMensagens.AppendText(msg_array[i].ToString());
            Thread.Sleep(30);
        }
    }

When I need to add something I will just call it with the desired string.

I think I should start a new Thread to do the WriteMessage (string msg) method, but I have no idea how it would look.

    
asked by anonymous 08.09.2017 / 21:45

0 answers