How to leave new form without depending on each other?

Asked

Viewed 64 times

-3

Here is the code that opens my Form4:

Form4 form4 = new Form4();
form4.Show();
// Aqui um código gigantesco que demora aproximadamente 1 minuto para ser executado.
form4.Close();

The problem is that while the Form4 is open, it is gray and static, not to move it or close. I understand that it gets kind of dependent on the code of the previous form, how to solve this?

  • more details of errors, exceptions

  • There is no exception.

  • close ends the application execution. if you want to close the form without closing the app, Hide instead of Close

  • You have to run your code in another thread, or asynchronously, so as not to block the UI thread. There are several ways to do this. Try for example putting the "gigantic code". inside a ThreadPool.QueueUserItem. If you give more details of your question let me know, and I will formulate an answer.

1 answer

1


Hello, take a look at: Long processing...

There is an answer posted by me and I believe it is a solution for you. Basically you need to start this second form in a Thread other than the one that runs the main processing, so the Forms are independent and when a long processing run the other form will not be frozen.

Hugs!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.