I have an application with 3 threads, this application involves a chemical process simulator, and I have to pick up some values from these processes. the values come in a single object.
The 3 threads make an infinite loop, in this loop they take the values at different times, which can not happen.
I wanted to know if I could sync threads, so when they get the object all 3 pick up at the same time.
Here are my threads:
public void RunController()
{
Softing.OPCToolbox.Client.Application app = Softing.OpcToolbox.Client.Application.Instance;
app.Initialize();
while(true)
{
scase.Solver.Integrator.IsRunning = true;
Thread.Sleep(1000);
scase.Solver.Integrator.IsRunning = false;
scase = Interaction.GetObject(opcform.pasta);
Contrl();
GC.Collect();
}
}
public void RunExport()
{
Softing.OPCToolbox.Client.Application app = Softing.OpcToolbox.Client.Application.Instance;
app.Initialize();
while(true)
{
scase.Solver.Integrator.IsRunning = true;
Thread.Sleep(1000);
scase.Solver.Integrator.IsRunning = false;
scase = Interaction.GetObject(opcform.pasta);
Exprt();
GC.Collect();
}
}
public void RunImport()
{
Softing.OPCToolbox.Client.Application app = Softing.OpcToolbox.Client.Application.Instance;
app.Initialize();
while(true)
{
scase.Solver.Integrator.IsRunning = true;
Thread.Sleep(1000);
scase.Solver.Integrator.IsRunning = false;
scase = Interaction.GetObject(opcform.pasta);
Imprt();
GC.Collect();
}
}
I would like them to run scase = Interaction.GetObject(opcform.pasta);
at the same time.