I have a common method in c#.
the ReadfromSource
method performs different operations based on the configuration parameters passed.
It performs operations like
- listening to a TCP port endlessly and receives the incoming data.
- listening to a http port endlessly and receives the incoming data.
- listening to a folder path endlessly and receives the incoming files.
public void ReadData(List<Configuration> configurations)
{
foreach(var config in configurations)
{
ReadfromSource(Configuration config);
}
}
public void ReadfromSource(Configuration config)
{
while(true)
{
// code for reading data from tcp port
thread.sleep(1000); //listens for each and every second
}
}
using multithreading, I need to run all the operations concurrently
how to implement the above scenario using mutithreading in c#, Thanks in Advance.