I am reading the text file consisting of 6 columns. Among 6 columns each 3 columns show one object information I want to access these columns in parallel through multithreading. Like 3 columns for one object, altogether 2 threads have created except main thread.
The text file looks like this:
I tried it but I face difficulty in passing data from the main thread to other threads error occurs at string variable "part". (variable part doesn't exist in the current context)
I want to do multithreading for tag1 and tag2.
I am sharing the block of my code, please suggest me where I am mistaken As I am new to multithread programming.
namespace MultiTag_Simulation_ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string line;
string[] part;
StreamReader File = new StreamReader("2Tags_Points.txt");
while((line = File.ReadLine()) !=null)
{
part = line.Split('\t');
Thread TAG1 = new Thread(new ThreadStart(Tag1));
TAG1.Start();
}
}
void Tag1()
{
double w, x;
w = Convert.ToDouble(part[1]);
x = Convert.ToDouble(part[2]);
Console.WriteLine("Tag1 x:" + w + "\t" + "Tag1 y:" + x);
Console.ReadKey();
}
}
}