Screen display is slow even after executing Form.ShowDialog method

taro 1 Reputation point
2020-11-10T00:47:32.48+00:00

Currently, I am conducting a continuous test to execute a SQL statement in an application created in C #.
If the continuous test is performed for about 3 to 4 hours, it will take about 5 seconds to display the screen by executing the Form.ShowDialog method.
Also, if you increase the time for continuous testing, the time required for screen display will increase accordingly.

Regarding the above, I am in trouble because the cause remains unknown.
Excuse me, but I would appreciate it if you could teach me the cause and investigation method for the above.

● Form.ShowDialog method
https://learn.microsoft.com/ja-jp/dotnet/api/system.windows.forms.form.showdialog?view=netcore-3.1

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,835 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,616 Reputation points
    2020-11-10T02:05:21.727+00:00

    Hi taro,
    Based on your description, I guess that the data is also loaded in the initialization, so you can try to load the data in the Form.load method.
    If the data you load is too large, I suggest that you can load the control directly. And then use another thread or asynchronously to load the data, then display the data on the control after loading.
    Loading a control is different from loading data, and more time will be wasted when loading data.
    So in order to find the cause of the problem more accurately, please provide some code snippets without personal information.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Daniel Zhang-MSFT 9,616 Reputation points
    2020-11-13T06:22:58.137+00:00

    Hi taro,
    First, I can't reproduce the situation without your code example.
    So I have some suggestions you can refer to and hope these are helpful to you.
    What is your dialog doing in Load and FormShown events?
    For the purpose of testing, comment out all the code that you have in the form constructor and let the second form display itself without data. Do you have the same lag?
    You need to analyze your code and figure out where the "slowdown" occurs. You can do this by analyzing your application. See What Are Some Good .NET Profilers? and Any decent C# profilers out there?.
    Menwhile, you need to show something while loading the data asynchronously, then show your dialog.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments