Home > other >  C# NET. Framework 2.0 | Make a delay?
C# NET. Framework 2.0 | Make a delay?

Time:05-27

How can I make my program wait 1 Second and then doing something? Like in NET. Framework 4.8 with Task.Delay() but I'm using NET. Framework 2.0 for a project for my old Windows 2000 Laptop. Is there something I can do?

    panel1.Visible = true;
    //delay
    panel2.Visible = true;
    //delay
    ...

CodePudding user response:

I see you are wanting to make UI panels be visible on a delay. One thing to avoid is any significant delay on the UI thread because your form will be unresponsive during that time and Users may think that it's crashed.

One good approach is to spawn a worker Thread to perform this delay action without blocking your UI thread. But when it comes time to change the UI panel to Visible it must be marshalled back onto the UI thread using Now the panels display progressively

  • Related