private static void PlayMelody(object parameter) { MelodyWrapper wrapper = (MelodyWrapper)parameter; Console.WriteLine(wrapper.Melody.Value); Thread.Sleep(1000); wrapper.Melody.Value = 2; }
private static void Main(string[] args) { var melody = new Melody { Value = 1 }; var wrapper = new MelodyWrapper { Melody = melody }; Thread melodyThread = new Thread(() => PlayMelody(wrapper)); melodyThread.Start(); melodyThread.Join(); Console.WriteLine(wrapper.Melody.Value); }
private static void PlayMelody(MelodyWrapper wrapper) { Console.WriteLine(wrapper.Melody.Value); Thread.Sleep(1000); wrapper.Melody.Value = 2; }