S
S
Sergey2020-02-20 23:57:55
C++ / C#
Sergey, 2020-02-20 23:57:55

ProgressBar does not work when implementing a loading screen. How can it be implemented?

I have a main form that takes a long time to load on startup. Let it be Form1. Decided to make a Splash Screen. In Form1_load, at the very beginning, I placed the code for launching the Splash Screen (Form2) form, and at the end of the Form1 load code, I closed Form2. It all works but there is a problem. progresBar on Form2 does not work while the code of Form1 is loaded. Tried to run asynchronously. I tried to make it the first to launch Form2 and from it start loading Form1. None of this worked. I understand that after opening Form2 and starting to load the Form1 code, Form2 becomes inactive. What can be done to make the ProgressBar work on Form2 while executing Form1's code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2020-02-21
@googlgan

Found it...
var splashThread = new Thread(new ThreadStart(
() => Application.Run(SplashScreen)));
splashThread.SetApartmentState(ApartmentState.STA);
splashThread.Start();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question