Home > Blockchain >  Show a form without freezing
Show a form without freezing

Time:05-17

I want to show a form but it's freezing, I already do background worker but it also doesn't work.

(I recreate my problem inside the method just need to full load the form)

public void show()
{
    Boolean test = false;
    BackgroundWorker worker = new BackgroundWorker();
    worker.DoWork  = delegate (object s, DoWorkEventArgs args)
    {
        while (!test)
        {
            try
            {
                Register dashboardServer = new Register();
                dashboardServer.Show();
                test = true;
            }
            catch (Exception eee)
            {

            }
        }
    };
    worker.RunWorkerAsync();
}

CodePudding user response:

I think what you're looking for is multithreading on Winforms. Here is a helpful link for you: https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/multithreading-in-windows-forms-controls?view=netframeworkdesktop-4.8. Please, bear in mind that this is the target to .NET Framework 4.8.

CodePudding user response:

BackgroundWorker is kind of obsolet.

You should take a look at async/await to run something asynchronous.

  •  Tags:  
  • c#
  • Related