This is my first time trying to implement a GUI using Windows Forms.
I have a question specific to my project but I will instead use another example that highlights my frustration:
Goal: A program that loop through a file directory and prompt users to rename its folders or not.
So say we have a button:
Start Service
Once the user hits this button the program does all its magic of looping through a directory. So say we have a directory:
A
- 1
- 2
B
-1
So say we only are looping through the top level directory the first folder we come up to in our loop is 'A'.
What I want is the flow of execution to halt here.
There are two more buttons above the 'Start Service button':
Rename
Ignore
I want the execution to halt until one of those two buttons are selected and then certain things happen depending on what the user selects.
I am having trouble with the 'halting' part of this. The last thing I tried:
ManualResetEvent mre = new ManualResetEvent(false);
In start service:
for (... some loop that goes through the directory){
var x = somethign[1] // "A";
mre.WaitOne();
}
In the function for the Rename Button Click Event:
//do some things
mre.Set();
But my form freezes up and it is not working properly. I am sure that this is possible and I just cant seem to figure it out. Can anyone point me in the right direction?