File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
src/Tests/MemoryModelTest Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Threading . Tasks ;
3+
4+ namespace MemoryModelTest ;
5+
6+ public static class MemoryTest
7+ {
8+
9+ #region Constants & Statics
10+
11+ public static async Task MemoryToSpanTestAsync ( )
12+ {
13+ await Task . Yield ( ) ;
14+
15+ Memory < int > memory = new int [ 5 ] ;
16+ var span = memory . Span ; // 高性能访问
17+ span [ 0 ] = 42 ;
18+
19+ Console . WriteLine ( span [ 0 ] ) ;
20+ }
21+
22+ #endregion
23+
24+ }
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+
13namespace MemoryModelTest ;
24
35internal static class Program
46{
57
68 #region Constants & Statics
79
8- public static void Main ( string [ ] args )
10+ public static async Task Main ( string [ ] args )
911 {
1012 //VolatileTest.Worker_Test();
1113 //Console.WriteLine();
@@ -34,7 +36,9 @@ public static void Main(string[] args)
3436
3537 //MemoryOwnerTest.SliceTest();
3638
37- SpanOwnerTest . Test ( ) ;
39+ //SpanOwnerTest.Test();
40+
41+ await MemoryTest . MemoryToSpanTestAsync ( ) ;
3842 }
3943
4044 #endregion
You can’t perform that action at this time.
0 commit comments