Hy,
In my project asp.net (c#), I am using threading to process some messages. I have a display page that contain a listbox with all the actions that are taken in processing the message. And a class where I am processing the message.
Default.aspx:
protected void Page_Load(object sender, EventArgs e)
{
//starts the thread and call the method from Process.cs
}
public void SetListItem(string text)
{
myListBox.Items.Add(text);
myListBox.DataBind();
}
Process.cs
public class Process
{
public Process()
{
Default defaultPage;
defaultPage.SetListItem("==> Received message!");
}
}
But the listbox do not show nothing.
Does anyone has any ideea where I’m wrong?
Thanks.
Jeff
Remove the databind
You don’t need it since you are adding an item to the list collection. If you were setting the DataSource property, you would then have to use it. This is all depending on where in the life-cycle your update is firing as well. It could be that your update is being replaced by code somewhere else in the process as well.
In truth, I would take this out of being a separate thread. Since you need it to be updated before the page submits information to the browser, you either need to keep it in the same thread to make sure it completes, or you’re going to need to have some sort of a check at the end of your page executing process to make sure it has finished. It is possible your thread is completing after the page has finished processing.