I have an issue with showing a complex modal dialog window and painting of the DataGridView’s on the main window. I think it is a timing issue.
It works fine on my dev environment. But not if I deploy to a production server and run it there.
public partial class DialogWindow : Form
public static void Show(string Caption)
using (var form = new DialogWindow())
form.Text = Caption;
To simulate cleanup of a complex form with a lot of dynamically added controls I have added a Sleep(5000).
Code in the click event of a button on the main form:
private void button1_Click(object sender, EventArgs e)
bindingSource1.Add(new Knight(Title.King, “Uther”, true));
bindingSource1.Add(new Knight(Title.King, “Arthur”, true));
bindingSource1.Add(new Knight(Title.Sir, “Mordred”, false));
bindingSource1.Add(new Knight(Title.Sir, “Gawain”, true));
bindingSource1.Add(new Knight(Title.Sir, “Galahad”, true));
dataGridView1.DataSource = bindingSource1;
If i run this on the production server the dataGridView is empty after the click on the button.
I have included a sample project that i hope demonstrate the problem.
Thanks for looking at this.
The behavior i get is that the grid remain empty after the 5 seconds. If I then hit the browser refresh button the page is refreshed and the 5 lines in the grid is there as they should be.
It is like everything on the page behind the seenes behaves as it shold. Just that the lines in the grid is not painted and clicking on where the lines should be also does nothing.
I see that it works on the amazon server so it must be something with my production server and the site configuration. Do you have any suggestions on what I should look for?
I can’t reproduce the issue. I tried locally and on a remote server (on amazon): http://demo.wisej.com/apps/delayeddialog
The code shows the dialog and enters the modal state at line 14 in DialogWindow.cs (form.ShowDialog()). After the user clicks OK or Cancel, execution resumes to the next line and then it’s suspended for 5 seconds (System.Threading.Thread.Sleep(5000)), after the 5 seconds delay the grid is populated.
What’s the behavior that you get on your server? Does the grid populate after the 5 seconds delay in the code?
When form.ShowDialog(); of DialogWindow.cs is hit, it halts execution of the code below the DialogWindow.Show("something");. In effect, nothing is loaded in the datagridview until after the DialogWindow is closed. I suggest you populate the datagridview in Load event of your main window. Please refer to https://wisej.com/docs/html/ModalWorkflow.htm. Hope this helps