My website includes a code-behind file and a separate class with a function that takes a significant amount of time to complete. I want to display information to the visitor when this function sends back a string.
To achieve this, I utilize a delegate to send a string back to the code-behind in the following manner:
public event Feedback feedbackInfo;
public EventArgs e = null;
public delegate void Feedback(String message, bool info);
Within my function, I implement FeedbackInfo("message", true);
which is received by the setFeedback code-behind function as shown below:
public void example() {
new Thread(delegate()
{
crypto = new EncryptNoLibraries(@"C:\Users\Robbie\TestDES\New Microsoft Visio Drawing.vsdx", @"C:\Users\Robbie\TestDES\New Microsoft Visio Drawing encrypted.vsdx");
crypto.feedbackInfo += new EncryptNoLibraries.Feedback(setFeedback);
object[] allArgs = { EncryptNoLibraries.CryptType.ENCRYPT, lstSleutels };
object args = allArgs;
crypto.DoCryptFile(args);
}).Start();
}
public void setFeedback(String message, bool info)
{
if (info)
{
if (!infoCell.Visible)
{
errorCell.Visible = false;
infoCell.Visible = true;
}
lblInfo.Text += String.Format("- {0}<br />", message);
}
else
{
if (!errorCell.Visible)
{
infoCell.Visible = false;
errorCell.Visible = true;
}
lblError.Text += String.Format("- {0}<br />", message);
}
}
The provided code segment showcases my webpage structure along with the use of JavaScript to update the panel through post-backs every 2.5 seconds. However, an issue arises where text in the label that should be updated gets lost upon triggering. The page's initial render differs from what is displayed after pushing the encrypt button, with not all messages appearing even after 2.5 seconds (some even disappear).
Before:
After:
What could be the possible cause for this problem?