user390130
user390130

Reputation: 11

Which event will be throw while the form is reloading after hiding the form?

I am having a form in my application Form1. A thread is running in this form. When i am showing the next form Form2, I am hiding this form and aborting the thread. When I am showing the parent form again , i need to restart the thread again.which event in the main form I can write thread restart code?

Upvotes: 1

Views: 87

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499760

While the VisibleChanged or Activated events may do this, I have to wonder why you don't just do it explicitly - it's your code that will be showing the form again, isn't it? Why not just create a new thread as part of the code that gets executed at that point?

As a side note, if you really are aborting the thread (with Thread.Abort) it would be worth moving to a more graceful shutdown procedure, setting a flag which the thread checks periodically. Hard aborts of threads are prone to leaving the application in an unknown state.

Upvotes: 2

Related Questions