C#: Two forms, one is calling the other one
Posted
by Shaza
on Stack Overflow
See other posts from Stack Overflow
or by Shaza
Published on 2010-05-07T22:15:20Z
Indexed on
2010/05/07
22:18 UTC
Read the original article
Hit count: 391
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??
© Stack Overflow or respective owner