I have a multi-threaded application in C# which tries to write to a TextBox in a Windows.Forms created by another thread.
As threads cannot modify what has not been created by them, I was using InvokeRequired as shown on 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 app, but apparently neither InvokeRequired nor BeginInvoke exist for TextBox in a Web.UI. What can I do?