I need to read a .txt that contains some variables that I need in other program. I explain it better: I have a program that makes a capture when it reads on a .txt some values, for example "1", "11", "111"... The problema that I have appears when I try to capture one or more images. It saves the correct number of captures, but all of them have the same information. I put my code below:
bool lecturaOK = false;
int time = 0;
while (!lecturaOK)
{
try
{
string text = System.IO.File.ReadAllText(@"prueba.txt");
if (text == "1" && time == 0)
{
time++;
using (BinaryWriter writer = new BinaryWriter(File.Open(@"kinect" + counter + @".stl", FileMode.Create)))
{
Helper.SaveBinaryStlMesh(mesh, writer, true, counter, posicionamiento);
}
counter++;
mesh = this.volume.CalculateMesh(1);
}
else if (text == "11" && time == 1)
{
time++;
using (BinaryWriter writer = new BinaryWriter(File.Open(@"kinect" + counter + @".stl", FileMode.Create)))
{
Helper.SaveBinaryStlMesh(mesh, writer, true, counter, posicionamiento);
}
counter++;
mesh = this.volume.CalculateMesh(1);
}
else if (text == "111" && time == 2)
{
time++;
using (BinaryWriter writer = new BinaryWriter(File.Open(@"kinect" + counter + @".stl", FileMode.Create)))
{
Helper.SaveBinaryStlMesh(mesh, writer, true, counter, posicionamiento);
}
counter++;
mesh = this.volume.CalculateMesh(1);
}
else if (text == "1111" && time == 3)
{
time++;
using (BinaryWriter writer = new BinaryWriter(File.Open(@"kinect" + counter + @".stl", FileMode.Create)))
{
Helper.SaveBinaryStlMesh(mesh, writer, true, counter, posicionamiento);
}
counter++;
mesh = this.volume.CalculateMesh(1);
}
else if (text == "11111" && time == 4)
{
time++;
using (BinaryWriter writer = new BinaryWriter(File.Open(@"kinect" + counter + @".stl", FileMode.Create)))
{
Helper.SaveBinaryStlMesh(mesh, writer, true, counter, posicionamiento);
}
counter++;
lecturaOK = true;
}
}
catch (Exception ex)
{
continue;
}
}
I restart the mesh value, but my program get stuck while it waits for the next txt values, I mean, it is only making the while loop and it doesn't make the "mesh = this.volume.CalculateMesh(1)" instruction. I need to wait for the values of the txt without stopping the rest of the program.
Is there any other way to do that?