Public Class Customer
{
public int CustomerId{get;set;}
Public string CustomerName{get;set;}
}
public class RunParallel(List<Customer> namelessCustomers)
{
Parallel.ForEach(namelessCustomers, (customer) =>{
var customerName = CallAPIToReturnCustomerName(customer.CustomerId);
customer.CustomerName = customerName
}
}
Hi is customer.CustomerName=customerName
thread safe. What I want is to update the list of customers so that each object get the customers name.
if not how can I get something like this to work. Also can you please explain why this would not be thread safe?