I have a multithreaded C # application that is trying to write to a TextBox on Windows.Forms created by another thread.
Since threads cannot change what was not created by them, I used InvokeRequired as shown in the code below to solve this problem.
public delegate void MessageDelegate(Communication message);
void agent_MessageReceived(Communication message)
{
if (InvokeRequired)
{
BeginInvoke(new MessageDelegate(agent_MessageReceived), new object[] { message });
}
else
{
TextBox1.Text += message.Body;
}
}
Now I need to do the same for a TextBox in an ASP.NET application, but apparently neither an InvokeRequired nor BeginInvoke exists for a TextBox in Web.UI. What can I do?
source
share