Imagine a List<MyStruct> that has x number of records in it. For each record in the List, a thread is created that goes and does something and then needs to update it's assigned record in the list.
The code below works in as much as it creates the threads and the threads can do their work because they can see what is in the record they are supposed to tend.
But they can't update the record in the List. They can, of course, modify their copy of the record, but that doesn't change the values of the record in the List. What I would like to do is pass in the List record by reference so that the thread can access it's record directly.
How do I pass an object to a thread by reference?
Thank you for your time,
Watcher my_watcher = new Watcher();
My_Struct a_rec = new My_Struct();
a_rec.s_a = "a";
a_rec.s_b = "b";
Thread fetcher_thread = new Thread(Fetcher);
//I want to be able to pass my_wather.SU_List by ref
public class Watcher
public struct My_Struct
public string s_a;
public string s_b;
public List<My_Struct> SU_List;
public void Fetcher(object _SU)
My_Struct SU = (My_Struct)_SU;
//now I can use SU, but not alter the 'original'