Hi,
I have a multi threaded application that also makes use of autoreset events.
Background:
The application is being used as a web service so I am exposing certain methods. I have a simple test harness that I can use to call the various exposed methods.
Problem:
At some point I call a run function like so in ObjectA :-
public void Run()
{
Thread tPeformRun = new Thread(PerformRun);
tPeformRun.Name = "ThreadName";
tPeformRun.IsBackground = true;
tPeformRun.Start();
}
Where PerformRun looks something like this:
private void PerformRun()
{
do
{
switch (Type)
{
case 1:
FunctionA();
break;
case 2:
FunctionB();
break;
}
} while (Continue);
Somewhere within FunctionA or B - I will call WaitOne on a autoreset event. This will be so that I can wait for some user interaction via the test harness.
When the user interaction takes place I then call a different function "Loaded" (below) on ObjectA, which will call Set on the same autoreset event that I called WaitOne on previously.
internal void Loaded()
{
// Do stuff...
AutoReset.Set();
}
However, the function happens to get called on a different thread to the one that I newed earlier on in Run, therefore the application sits and waits forever.
Can somebody please offer some guidance as to how I should design this or a solution as I am not sure where to go next with this.
Thanks so much in advance.
Joe