Reputation: 23
i got the following windows form come:
if (richTextBoxReceive.InvokeRequired)
{
richTextBoxReceive.Invoke(new MethodInvoker(()=>
richTextBoxReceive.AppendText(string.Format("{0}\n\r", msg))));
}
else
{
richTextBoxReceive.AppendText(string.Format("{0}\n\r", msg));
}
i am using this code in WPF aplication and when i replace whit
if (richTextBoxReceive.Dispatcher.CheckAccess())
{
richTextBoxReceive.Dispatcher.Invoke(new MethodInvoker(()=>
richTextBoxReceive.AppendText(string.Format("{0}\n\r", msg))));
}
else
{
richTextBoxReceive.AppendText(string.Format("{0}\n\r", msg));
}
im getting 3 errors:
1)Error : WpfApplication1.MethodInvoker does not contain a constructor that takes 1 argument
2)Error : Argument 1: cannot convert from 'WpfApplication1.MethodInvoker to System.Delegate
3)Error : The best overloaded method match for System.Windows.Threading.Dispatcher.Invoke(System.Delegate, params object[]) has some invalid arguments
I am new to WPF... i hope i didn t put any dumb question , if u got a solution for my problem pleas help me Thanks very much !
Upvotes: 0
Views: 2574