I am working on .NET CORE 3.1 applications. I have record object of two types which call same method to process data and in return add to same list. I modify code from classic loop to thread. so I created two threads and objective that I can improve performance however if I run both threads I don't get result but if I do just one thread then it do work and get result... not sure what I am missing from puzzle.
Thread processThreadA = new Thread(async () =>
{
var processedNonInbound= await MethodX(data);
returnList.AddRange(processedNonInbound);
});
Thread processThreadB = new Thread(async () =>
{
var processInbound = await MethodX(data);
returnList.AddRange(processInbound);
});
processThreadA.Start();
processThreadB.Start();
processThreadA.Join();
processThreadB.Join();
Method that called by thread:
private async Task<List<Customers>> MethodX(Record r){
//.....
}