I have a main form in the program and several children. How to make it so that while another form works, the main one "falls asleep"?

Closed due to the fact that the essence of the question is not clear to the participants 0xdb , Sergey Glazirin , Kromster , Enikeyschik , Denis Bubnov December 4, '18 at 7:09 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    What exactly does "fall asleep" mean? Did not respond to user input? Open the second window as modal. - VladD
  • @VladD Fell asleep, specifically it wore a pajamas and lay down in the crib. TC, please do not use in the question expressions and language that can be understood in two ways. - 0xdb
  • @ 0xdb: If so, I would advise to sing her a lullaby. But seriously, the TC, I think, confuses the form itself as a UI element and model processes launched by this form itself. Hence my question. - VladD 1:16 pm

2 answers 2

Call the child form not through form.Show(); , and through form.ShowDialog(); .

    You need to connect the library System.Windows.Threading , then for each form to create a separate thread

     Thread th1=new Thread(); Thread th2=new Thread(); 

    using methods

     .Sleep() .Start() 

    enable / disable threads

    • 2
      Thread.Sleep means not at all what you expect. This function does not allow to “put to sleep" someone else's stream. - VladD