C#: Two forms, one is calling the other one
- by Shaza
Hey all,
I have a problem like this, I have two Winforms, f1 and f2.
f1 will start a loop on button click, this loop checks a condition and decide to call the other form which is f2 or not.
The problem is, the loop may call f2 many times, so each time the other form f2 will be called the first form f1 should pause its execution.
So, I solved it like this, I used backgroundWorker + AutoResetEvent. I placed the backgroundWorker in the first form and inside the DoWork event handler I called f2.Show()
then I called WaitOne on the AutoResetEvent let it be A.
In the other form "f2", on Exiting button I called Set on the same A.
But, unfortunately f2 got freezed when clicking that button in f1, what should I change??