Using the C# Dispatcher in WPF Applications

后端 未结 3 1359
一向
一向 2020-11-29 00:45

I\'m building a chat client and am not 100% sure on how to use the dispatcher. So the question is I have a method as such:

public void LostConne         


        
3条回答
  •  萌比男神i
    2020-11-29 01:23

    Something like this (off the top of my head) should work:

    public void LostConnection() 
    { 
       myGUI.Invoke
          ((MethodInvoker)delegate
       {
          myGUI.chatBox.AppendText("Lost connection to room: "+ myGUI.UsernameText.ToString() + "\r\n"); 
       });
    }
    

提交回复
热议问题