public static async Task RefStructAsync(/*ref*/ MySs ss) //Async methods cannot have ref or out parameters { Console.WriteLine($"befor async - {nameof(ss._xx)}={ss._xx}, {nameof(ss._yy)}={ss._yy}"); await Task.Delay(20_000); Console.WriteLine($"after async - {nameof(ss._xx)}={ss._xx}, {nameof(ss._yy)}={ss._yy}"); }
public static void Case0() { MySs ss = new MySs { _xx = 100, _yy = 100, }; RefStruct(ref ss); }
public static async Task Case1Async() { int _10sec = 10_000; MySs myss = new MySs(); await Task.Delay(_10sec); RefStruct(ref myss); await Task.Delay(_10sec); RefStruct(ref myss); await Task.Delay(_10sec); }
public static void RefStruct(ref MySs ss) { Console.WriteLine($"befor async - {nameof(ss._xx)}={ss._xx}, {nameof(ss._yy)}={ss._yy}"); Task.Delay(20_000).Wait(); Console.WriteLine($"after async - {nameof(ss._xx)}={ss._xx}, {nameof(ss._yy)}={ss._yy}"); }