编程语言
首页 > 编程语言> > C# yield return 原理探究

C# yield return 原理探究

作者:互联网

天需要些一个小工具,需要使用到多线程读写程序集,接口方法返回值类型需要为"IEnumerable<string>"这里用到了"yield return",但是同时也使用了同步锁,为了确认代码没有问题,决定分析下 yield 的实现原理,测试代码如下:

class Program
{public static void Main(string[] args)
    {
        IEnumerable<string> coll = CreateCollection();foreach (string str in coll)
        {
            Console.WriteLine($"read: {str}");
        }
    }private static IEnumerable<string> CreateCollection()
    {using (BlockingCollection<string> collection = new BlockingCollection<string>())
        {lock (globalLock)
            {
                Exception err = null;
                Task.Factory.StartNew(() =>{lock (globalLock)
                    {for (int i = 0; i < 10; i++)
                        {
                            Thread.Sleep(100);string value = $"value: {i}";
                            Console.WriteLine($"write: {value}");
                            collection.Add($"value: {i}");
                            Console.WriteLine($"end write: {value}");
                        }
                    }
                }).ContinueWith((task) =>{
                    collection.CompleteAdding();
                    err = task.Exception;
                });
            }foreach (string item in collection.GetConsumingEnumerable())
            {yield return item;
            }
        }
    }private static readonly object globalLock = new object();
}

运行以上代码,结果如下:

yield return with multi thread result

结果是期望结果,但无法确定是否有其他问题,所以决定查看下IL代码,如下:

  1 // Token: 0x02000002 RID: 2  2 .class private auto ansi beforefieldinit ConsoleApp1.Program  3     extends [mscorlib]System.Object  4 {  5     // Nested Types  6     // Token: 0x02000003 RID: 3  7     .class nested private auto ansi sealed beforefieldinit '<>c__DisplayClass1_0'  8         extends [mscorlib]System.Object  9     { 10         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 11             01 00 00 00 12         ) 13         // Fields 14         // Token: 0x04000002 RID: 2 15         .field public class [System]System.Collections.Concurrent.BlockingCollection`1<string> collection 16  17         // Methods 18         // Token: 0x06000005 RID: 5 RVA: 0x000020CE File Offset: 0x000002CE 19         .method public hidebysig specialname rtspecialname  20             instance void .ctor () cil managed  21         { 22             // Header Size: 1 byte 23             // Code Size: 8 (0x8) bytes 24             .maxstack 8 25  26             /* 0x000002CF 02           */ IL_0000: ldarg.0 27             /* 0x000002D0 281A00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor() 28             /* 0x000002D5 00           */ IL_0006: nop 29             /* 0x000002D6 2A           */ IL_0007: ret 30         } // end of method '<>c__DisplayClass1_0'::.ctor 31  32         // Token: 0x06000006 RID: 6 RVA: 0x000020D8 File Offset: 0x000002D8 33         .method assembly hidebysig  34             instance void '<CreateCollection>b__0' () cil managed  35         { 36             // Header Size: 12 bytes 37             // Code Size: 142 (0x8E) bytes 38             // LocalVarSig Token: 0x11000002 RID: 2 39             .maxstack 3 40             .locals init ( 41                 [0] object, 42                 [1] bool, 43                 [2] int32 i, 44                 [3] string 'value', 45                 [4] bool 46             ) 47  48             /* (31,21)-(31,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 49             /* 0x000002E4 00           */ IL_0000: nop 50             /* (32,25)-(32,42) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 51             /* 0x000002E5 7E01000004   */ IL_0001: ldsfld    object ConsoleApp1.Program::globalLock 52             /* 0x000002EA 0A           */ IL_0006: stloc.0 53             /* 0x000002EB 16           */ IL_0007: ldc.i4.0 54             /* 0x000002EC 0B           */ IL_0008: stloc.1 55             .try 56             { 57                 /* 0x000002ED 06           */ IL_0009: ldloc.0 58                 /* 0x000002EE 1201         */ IL_000A: ldloca.s  V_1 59                 /* 0x000002F0 281B00000A   */ IL_000C: call      void [mscorlib]System.Threading.Monitor::Enter(object, bool&) 60                 /* 0x000002F5 00           */ IL_0011: nop 61                 /* (33,25)-(33,26) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 62                 /* 0x000002F6 00           */ IL_0012: nop 63                 /* (34,34)-(34,43) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 64                 /* 0x000002F7 16           */ IL_0013: ldc.i4.0 65                 /* 0x000002F8 0C           */ IL_0014: stloc.2 66                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 67                 /* 0x000002F9 2B5D         */ IL_0015: br.s      IL_0074 68                 // loop start (head: IL_0074) 69                     /* (35,29)-(35,30) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 70                     /* 0x000002FB 00           */ IL_0017: nop 71                     /* (36,33)-(36,51) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 72                     /* 0x000002FC 1F64         */ IL_0018: ldc.i4.s  100 73                     /* 0x000002FE 281C00000A   */ IL_001A: call      void [mscorlib]System.Threading.Thread::Sleep(int32) 74                     /* 0x00000303 00           */ IL_001F: nop 75                     /* (37,33)-(37,62) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 76                     /* 0x00000304 720F000070   */ IL_0020: ldstr     "value: {0}" 77                     /* 0x00000309 08           */ IL_0025: ldloc.2 78                     /* 0x0000030A 8C1F000001   */ IL_0026: box       [mscorlib]System.Int32 79                     /* 0x0000030F 281D00000A   */ IL_002B: call      string [mscorlib]System.String::Format(string, object) 80                     /* 0x00000314 0D           */ IL_0030: stloc.3 81                     /* (38,33)-(38,70) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 82                     /* 0x00000315 7225000070   */ IL_0031: ldstr     "write: " 83                     /* 0x0000031A 09           */ IL_0036: ldloc.3 84                     /* 0x0000031B 281800000A   */ IL_0037: call      string [mscorlib]System.String::Concat(string, string) 85                     /* 0x00000320 281900000A   */ IL_003C: call      void [mscorlib]System.Console::WriteLine(string) 86                     /* 0x00000325 00           */ IL_0041: nop 87                     /* (39,33)-(39,63) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 88                     /* 0x00000326 02           */ IL_0042: ldarg.0 89                     /* 0x00000327 7B02000004   */ IL_0043: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 90                     /* 0x0000032C 720F000070   */ IL_0048: ldstr     "value: {0}" 91                     /* 0x00000331 08           */ IL_004D: ldloc.2 92                     /* 0x00000332 8C1F000001   */ IL_004E: box       [mscorlib]System.Int32 93                     /* 0x00000337 281D00000A   */ IL_0053: call      string [mscorlib]System.String::Format(string, object) 94                     /* 0x0000033C 6F1E00000A   */ IL_0058: callvirt  instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::Add(!0) 95                     /* 0x00000341 00           */ IL_005D: nop 96                     /* (40,33)-(40,74) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 97                     /* 0x00000342 7235000070   */ IL_005E: ldstr     "end write: " 98                     /* 0x00000347 09           */ IL_0063: ldloc.3 99                     /* 0x00000348 281800000A   */ IL_0064: call      string [mscorlib]System.String::Concat(string, string)100                     /* 0x0000034D 281900000A   */ IL_0069: call      void [mscorlib]System.Console::WriteLine(string)101                     /* 0x00000352 00           */ IL_006E: nop102                     /* (41,29)-(41,30) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */103                     /* 0x00000353 00           */ IL_006F: nop104                     /* (34,53)-(34,56) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */105                     /* 0x00000354 08           */ IL_0070: ldloc.2106                     /* 0x00000355 17           */ IL_0071: ldc.i4.1107                     /* 0x00000356 58           */ IL_0072: add108                     /* 0x00000357 0C           */ IL_0073: stloc.2109 110                     /* (34,45)-(34,51) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */111                     /* 0x00000358 08           */ IL_0074: ldloc.2112                     /* 0x00000359 1F0A         */ IL_0075: ldc.i4.s  10113                     /* 0x0000035B FE04         */ IL_0077: clt114                     /* 0x0000035D 1304         */ IL_0079: stloc.s   V_4115                     /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */116                     /* 0x0000035F 1104         */ IL_007B: ldloc.s   V_4117                     /* 0x00000361 2D98         */ IL_007D: brtrue.s  IL_0017118                 // end loop119 120                 /* (42,25)-(42,26) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */121                 /* 0x00000363 00           */ IL_007F: nop122                 /* 0x00000364 DE0B         */ IL_0080: leave.s   IL_008D123             } // end .try124             finally125             {126                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */127                 /* 0x00000366 07           */ IL_0082: ldloc.1128                 /* 0x00000367 2C07         */ IL_0083: brfalse.s IL_008C129 130                 /* 0x00000369 06           */ IL_0085: ldloc.0131                 /* 0x0000036A 281F00000A   */ IL_0086: call      void [mscorlib]System.Threading.Monitor::Exit(object)132                 /* 0x0000036F 00           */ IL_008B: nop133 134                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */135                 /* 0x00000370 DC           */ IL_008C: endfinally136             } // end handler137 138             /* (43,21)-(43,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */139             /* 0x00000371 2A           */ IL_008D: ret140         } // end of method '<>c__DisplayClass1_0'::'<CreateCollection>b__0'141 142     } // end of class <>c__DisplayClass1_0143 144     // Token: 0x02000004 RID: 4145     .class nested private auto ansi sealed beforefieldinit '<>c__DisplayClass1_1'146         extends [mscorlib]System.Object147     {148         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (149             01 00 00 00150         )151         // Fields152         // Token: 0x04000003 RID: 3153         .field public class [mscorlib]System.Exception err154         // Token: 0x04000004 RID: 4155         .field public class ConsoleApp1.Program/'<>c__DisplayClass1_0' 'CS$<>8__locals1'156 157         // Methods158         // Token: 0x06000007 RID: 7 RVA: 0x00002184 File Offset: 0x00000384159         .method public hidebysig specialname rtspecialname 160             instance void .ctor () cil managed 161         {162             // Header Size: 1 byte163             // Code Size: 8 (0x8) bytes164             .maxstack 8165 166             /* 0x00000385 02           */ IL_0000: ldarg.0167             /* 0x00000386 281A00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor()168             /* 0x0000038B 00           */ IL_0006: nop169             /* 0x0000038C 2A           */ IL_0007: ret170         } // end of method '<>c__DisplayClass1_1'::.ctor171 172         // Token: 0x06000008 RID: 8 RVA: 0x0000218D File Offset: 0x0000038D173         .method assembly hidebysig 174             instance void '<CreateCollection>b__1' (175                 class [mscorlib]System.Threading.Tasks.Task task176             ) cil managed 177         {178             // Header Size: 1 byte179             // Code Size: 31 (0x1F) bytes180             .maxstack 8181 182             /* (44,21)-(44,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */183             /* 0x0000038E 00           */ IL_0000: nop184             /* (45,25)-(45,53) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */185             /* 0x0000038F 02           */ IL_0001: ldarg.0186             /* 0x00000390 7B04000004   */ IL_0002: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1'187             /* 0x00000395 7B02000004   */ IL_0007: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection188             /* 0x0000039A 6F2000000A   */ IL_000C: callvirt  instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::CompleteAdding()189             /* 0x0000039F 00           */ IL_0011: nop190             /* (46,25)-(46,46) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */191             /* 0x000003A0 02           */ IL_0012: ldarg.0192             /* 0x000003A1 03           */ IL_0013: ldarg.1193             /* 0x000003A2 6F2100000A   */ IL_0014: callvirt  instance class [mscorlib]System.AggregateException [mscorlib]System.Threading.Tasks.Task::get_Exception()194             /* 0x000003A7 7D03000004   */ IL_0019: stfld     class [mscorlib]System.Exception ConsoleApp1.Program/'<>c__DisplayClass1_1'::err195             /* (47,21)-(47,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */196             /* 0x000003AC 2A           */ IL_001E: ret197         } // end of method '<>c__DisplayClass1_1'::'<CreateCollection>b__1'198 199     } // end of class <>c__DisplayClass1_1200 201     // Token: 0x02000005 RID: 5202     .class nested private auto ansi sealed beforefieldinit '<CreateCollection>d__1'203         extends [mscorlib]System.Object204         implements class [mscorlib]System.Collections.Generic.IEnumerable`1<string>,205                    [mscorlib]System.Collections.IEnumerable,206                    class [mscorlib]System.Collections.Generic.IEnumerator`1<string>,207                    [mscorlib]System.IDisposable,208                    [mscorlib]System.Collections.IEnumerator209     {210         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (211             01 00 00 00212         )213         // Fields214         // Token: 0x04000005 RID: 5215         .field private int32 '<>1__state'216         // Token: 0x04000006 RID: 6217         .field private string '<>2__current'218         // Token: 0x04000007 RID: 7219         .field private int32 '<>l__initialThreadId'220         // Token: 0x04000008 RID: 8221         .field private class ConsoleApp1.Program/'<>c__DisplayClass1_0' '<>8__1'222         // Token: 0x04000009 RID: 9223         .field private object '<>s__2'224         // Token: 0x0400000A RID: 10225         .field private bool '<>s__3'226         // Token: 0x0400000B RID: 11227         .field private class ConsoleApp1.Program/'<>c__DisplayClass1_1' '<>8__4'228         // Token: 0x0400000C RID: 12229         .field private class [mscorlib]System.Collections.Generic.IEnumerator`1<string> '<>s__5'230         // Token: 0x0400000D RID: 13231         .field private string '<item>5__6'232 233         // Methods234         // Token: 0x06000009 RID: 9 RVA: 0x000021AD File Offset: 0x000003AD235         .method public hidebysig specialname rtspecialname 236             instance void .ctor (237                 int32 '<>1__state'238             ) cil managed 239         {240             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (241                 01 00 00 00242             )243             // Header Size: 1 byte244             // Code Size: 31 (0x1F) bytes245             .maxstack 8246 247             /* 0x000003AE 02           */ IL_0000: ldarg.0248             /* 0x000003AF 281A00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor()249             /* 0x000003B4 00           */ IL_0006: nop250             /* 0x000003B5 02           */ IL_0007: ldarg.0251             /* 0x000003B6 03           */ IL_0008: ldarg.1252             /* 0x000003B7 7D05000004   */ IL_0009: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'253             /* 0x000003BC 02           */ IL_000E: ldarg.0254             /* 0x000003BD 282200000A   */ IL_000F: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread()255             /* 0x000003C2 6F2300000A   */ IL_0014: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId()256             /* 0x000003C7 7D07000004   */ IL_0019: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>l__initialThreadId'257             /* 0x000003CC 2A           */ IL_001E: ret258         } // end of method '<CreateCollection>d__1'::.ctor259 260         // Token: 0x0600000A RID: 10 RVA: 0x000021D0 File Offset: 0x000003D0261         .method private final hidebysig newslot virtual 262             instance void System.IDisposable.Dispose () cil managed 263         {264             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (265                 01 00 00 00266             )267             .override method instance void [mscorlib]System.IDisposable::Dispose()268             // Header Size: 12 bytes269             // Code Size: 60 (0x3C) bytes270             // LocalVarSig Token: 0x11000003 RID: 3271             .maxstack 2272             .locals init (273                 [0] int32274             )275 276             /* 0x000003DC 02           */ IL_0000: ldarg.0277             /* 0x000003DD 7B05000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'278             /* 0x000003E2 0A           */ IL_0006: stloc.0279             /* 0x000003E3 06           */ IL_0007: ldloc.0280             /* 0x000003E4 1FFC         */ IL_0008: ldc.i4.s  -4281             /* 0x000003E6 59           */ IL_000A: sub282             /* 0x000003E7 17           */ IL_000B: ldc.i4.1283             /* 0x000003E8 3608         */ IL_000C: ble.un.s  IL_0016284 285             /* 0x000003EA 2B00         */ IL_000E: br.s      IL_0010286 287             /* 0x000003EC 06           */ IL_0010: ldloc.0288             /* 0x000003ED 17           */ IL_0011: ldc.i4.1289             /* 0x000003EE 2E02         */ IL_0012: beq.s     IL_0016290 291             /* 0x000003F0 2B25         */ IL_0014: br.s      IL_003B292 293             /* 0x000003F2 00           */ IL_0016: nop294             .try295             {296                 /* 0x000003F3 06           */ IL_0017: ldloc.0297                 /* 0x000003F4 1FFC         */ IL_0018: ldc.i4.s  -4298                 /* 0x000003F6 2E08         */ IL_001A: beq.s     IL_0024299 300                 /* 0x000003F8 2B00         */ IL_001C: br.s      IL_001E301 302                 /* 0x000003FA 06           */ IL_001E: ldloc.0303                 /* 0x000003FB 17           */ IL_001F: ldc.i4.1304                 /* 0x000003FC 2E02         */ IL_0020: beq.s     IL_0024305 306                 /* 0x000003FE 2B0C         */ IL_0022: br.s      IL_0030307 308                 /* 0x00000400 00           */ IL_0024: nop309                 .try310                 {311                     /* 0x00000401 DE07         */ IL_0025: leave.s   IL_002E312                 } // end .try313                 finally314                 {315                     /* 0x00000403 02           */ IL_0027: ldarg.0316                     /* 0x00000404 280D000006   */ IL_0028: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally2'()317                     /* 0x00000409 DC           */ IL_002D: endfinally318                 } // end handler319 320                 /* 0x0000040A 2B00         */ IL_002E: br.s      IL_0030321 322                 /* 0x0000040C DE07         */ IL_0030: leave.s   IL_0039323             } // end .try324             finally325             {326                 /* 0x0000040E 02           */ IL_0032: ldarg.0327                 /* 0x0000040F 280C000006   */ IL_0033: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally1'()328                 /* 0x00000414 DC           */ IL_0038: endfinally329             } // end handler330 331             /* 0x00000415 2B00         */ IL_0039: br.s      IL_003B332 333             /* 0x00000417 2A           */ IL_003B: ret334         } // end of method '<CreateCollection>d__1'::System.IDisposable.Dispose335 336         // Token: 0x0600000B RID: 11 RVA: 0x00002234 File Offset: 0x00000434337         .method private final hidebysig newslot virtual 338             instance bool MoveNext () cil managed 339         {340             .override method instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()341             // Header Size: 12 bytes342             // Code Size: 397 (0x18D) bytes343             // LocalVarSig Token: 0x11000004 RID: 4344             .maxstack 3345             .locals init (346                 [0] bool,347                 [1] int32348             )349 350             .try351             {352                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */353                 /* 0x00000440 02           */ IL_0000: ldarg.0354                 /* 0x00000441 7B05000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'355                 /* 0x00000446 0B           */ IL_0006: stloc.1356                 /* 0x00000447 07           */ IL_0007: ldloc.1357                 /* 0x00000448 2C08         */ IL_0008: brfalse.s IL_0012358 359                 /* 0x0000044A 2B00         */ IL_000A: br.s      IL_000C360 361                 /* 0x0000044C 07           */ IL_000C: ldloc.1362                 /* 0x0000044D 17           */ IL_000D: ldc.i4.1363                 /* 0x0000044E 2E04         */ IL_000E: beq.s     IL_0014364 365                 /* 0x00000450 2B07         */ IL_0010: br.s      IL_0019366 367                 /* 0x00000452 2B0C         */ IL_0012: br.s      IL_0020368 369                 /* 0x00000454 382C010000   */ IL_0014: br        IL_0145370 371                 /* 0x00000459 16           */ IL_0019: ldc.i4.0372                 /* 0x0000045A 0A           */ IL_001A: stloc.0373                 /* 0x0000045B DD6B010000   */ IL_001B: leave     IL_018B374 375                 /* 0x00000460 02           */ IL_0020: ldarg.0376                 /* 0x00000461 15           */ IL_0021: ldc.i4.m1377                 /* 0x00000462 7D05000004   */ IL_0022: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'378                 /* (24,9)-(24,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */379                 /* 0x00000467 00           */ IL_0027: nop380                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */381                 /* 0x00000468 02           */ IL_0028: ldarg.0382                 /* 0x00000469 7305000006   */ IL_0029: newobj    instance void ConsoleApp1.Program/'<>c__DisplayClass1_0'::.ctor()383                 /* 0x0000046E 7D08000004   */ IL_002E: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'384                 /* (25,20)-(25,92) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */385                 /* 0x00000473 02           */ IL_0033: ldarg.0386                 /* 0x00000474 7B08000004   */ IL_0034: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'387                 /* 0x00000479 732400000A   */ IL_0039: newobj    instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::.ctor()388                 /* 0x0000047E 7D02000004   */ IL_003E: stfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection389                 /* 0x00000483 02           */ IL_0043: ldarg.0390                 /* 0x00000484 1FFD         */ IL_0044: ldc.i4.s  -3391                 /* 0x00000486 7D05000004   */ IL_0046: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'392                 /* (26,13)-(26,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */393                 /* 0x0000048B 00           */ IL_004B: nop394                 /* (27,17)-(27,34) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */395                 /* 0x0000048C 02           */ IL_004C: ldarg.0396                 /* 0x0000048D 7E01000004   */ IL_004D: ldsfld    object ConsoleApp1.Program::globalLock397                 /* 0x00000492 7D09000004   */ IL_0052: stfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2'398                 /* 0x00000497 02           */ IL_0057: ldarg.0399                 /* 0x00000498 16           */ IL_0058: ldc.i4.0400                 /* 0x00000499 7D0A000004   */ IL_0059: stfld     bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3'401                 .try402                 {403                     /* 0x0000049E 02           */ IL_005E: ldarg.0404                     /* 0x0000049F 7B09000004   */ IL_005F: ldfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2'405                     /* 0x000004A4 02           */ IL_0064: ldarg.0406                     /* 0x000004A5 7C0A000004   */ IL_0065: ldflda    bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3'407                     /* 0x000004AA 281B00000A   */ IL_006A: call      void [mscorlib]System.Threading.Monitor::Enter(object, bool&)408                     /* 0x000004AF 00           */ IL_006F: nop409                     /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */410                     /* 0x000004B0 02           */ IL_0070: ldarg.0411                     /* 0x000004B1 7307000006   */ IL_0071: newobj    instance void ConsoleApp1.Program/'<>c__DisplayClass1_1'::.ctor()412                     /* 0x000004B6 7D0B000004   */ IL_0076: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'413                     /* 0x000004BB 02           */ IL_007B: ldarg.0414                     /* 0x000004BC 7B0B000004   */ IL_007C: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'415                     /* 0x000004C1 02           */ IL_0081: ldarg.0416                     /* 0x000004C2 7B08000004   */ IL_0082: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'417                     /* 0x000004C7 7D04000004   */ IL_0087: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1'418                     /* (28,17)-(28,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */419                     /* 0x000004CC 00           */ IL_008C: nop420                     /* (29,21)-(29,42) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */421                     /* 0x000004CD 02           */ IL_008D: ldarg.0422                     /* 0x000004CE 7B0B000004   */ IL_008E: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'423                     /* 0x000004D3 14           */ IL_0093: ldnull424                     /* 0x000004D4 7D03000004   */ IL_0094: stfld     class [mscorlib]System.Exception ConsoleApp1.Program/'<>c__DisplayClass1_1'::err425                     /* (30,21)-(47,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */426                     /* 0x000004D9 282500000A   */ IL_0099: call      class [mscorlib]System.Threading.Tasks.TaskFactory [mscorlib]System.Threading.Tasks.Task::get_Factory()427                     /* 0x000004DE 02           */ IL_009E: ldarg.0428                     /* 0x000004DF 7B0B000004   */ IL_009F: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'429                     /* 0x000004E4 7B04000004   */ IL_00A4: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1'430                     /* 0x000004E9 FE0606000006 */ IL_00A9: ldftn     instance void ConsoleApp1.Program/'<>c__DisplayClass1_0'::'<CreateCollection>b__0'()431                     /* 0x000004EF 732600000A   */ IL_00AF: newobj    instance void [mscorlib]System.Action::.ctor(object, native int)432                     /* 0x000004F4 6F2700000A   */ IL_00B4: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.TaskFactory::StartNew(class [mscorlib]System.Action)433                     /* 0x000004F9 02           */ IL_00B9: ldarg.0434                     /* 0x000004FA 7B0B000004   */ IL_00BA: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'435                     /* 0x000004FF FE0608000006 */ IL_00BF: ldftn     instance void ConsoleApp1.Program/'<>c__DisplayClass1_1'::'<CreateCollection>b__1'(class [mscorlib]System.Threading.Tasks.Task)436                     /* 0x00000505 732800000A   */ IL_00C5: newobj    instance void class [mscorlib]System.Action`1<class [mscorlib]System.Threading.Tasks.Task>::.ctor(object, native int)437                     /* 0x0000050A 6F2900000A   */ IL_00CA: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.Task::ContinueWith(class [mscorlib]System.Action`1<class [mscorlib]System.Threading.Tasks.Task>)438                     /* 0x0000050F 26           */ IL_00CF: pop439                     /* (48,17)-(48,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */440                     /* 0x00000510 00           */ IL_00D0: nop441                     /* 0x00000511 02           */ IL_00D1: ldarg.0442                     /* 0x00000512 14           */ IL_00D2: ldnull443                     /* 0x00000513 7D0B000004   */ IL_00D3: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4'444                     /* 0x00000518 DE15         */ IL_00D8: leave.s   IL_00EF445                 } // end .try446                 finally447                 {448                     /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */449                     /* 0x0000051A 02           */ IL_00DA: ldarg.0450                     /* 0x0000051B 7B0A000004   */ IL_00DB: ldfld     bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3'451                     /* 0x00000520 2C0C         */ IL_00E0: brfalse.s IL_00EE452 453                     /* 0x00000522 02           */ IL_00E2: ldarg.0454                     /* 0x00000523 7B09000004   */ IL_00E3: ldfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2'455                     /* 0x00000528 281F00000A   */ IL_00E8: call      void [mscorlib]System.Threading.Monitor::Exit(object)456                     /* 0x0000052D 00           */ IL_00ED: nop457 458                     /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */459                     /* 0x0000052E DC           */ IL_00EE: endfinally460                 } // end handler461 462                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */463                 /* 0x0000052F 02           */ IL_00EF: ldarg.0464                 /* 0x00000530 14           */ IL_00F0: ldnull465                 /* 0x00000531 7D09000004   */ IL_00F1: stfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2'466                 /* (50,17)-(50,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */467                 /* 0x00000536 00           */ IL_00F6: nop468                 /* (50,41)-(50,76) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */469                 /* 0x00000537 02           */ IL_00F7: ldarg.0470                 /* 0x00000538 02           */ IL_00F8: ldarg.0471                 /* 0x00000539 7B08000004   */ IL_00F9: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'472                 /* 0x0000053E 7B02000004   */ IL_00FE: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection473                 /* 0x00000543 6F2A00000A   */ IL_0103: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerable`1<!0> class [System]System.Collections.Concurrent.BlockingCollection`1<string>::GetConsumingEnumerable()474                 /* 0x00000548 6F1500000A   */ IL_0108: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator()475                 /* 0x0000054D 7D0C000004   */ IL_010D: stfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'476                 /* 0x00000552 02           */ IL_0112: ldarg.0477                 /* 0x00000553 1FFC         */ IL_0113: ldc.i4.s  -4478                 /* 0x00000555 7D05000004   */ IL_0115: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'479                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */480                 /* 0x0000055A 2B39         */ IL_011A: br.s      IL_0155481 482                 /* (50,26)-(50,37) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */483                 /* 0x0000055C 02           */ IL_011C: ldarg.0484                 /* 0x0000055D 02           */ IL_011D: ldarg.0485                 /* 0x0000055E 7B0C000004   */ IL_011E: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'486                 /* 0x00000563 6F1200000A   */ IL_0123: callvirt  instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current()487                 /* 0x00000568 7D0D000004   */ IL_0128: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6'488                 /* (51,17)-(51,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */489                 /* 0x0000056D 00           */ IL_012D: nop490                 /* (52,21)-(52,39) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */491                 /* 0x0000056E 02           */ IL_012E: ldarg.0492                 /* 0x0000056F 02           */ IL_012F: ldarg.0493                 /* 0x00000570 7B0D000004   */ IL_0130: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6'494                 /* 0x00000575 7D06000004   */ IL_0135: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current'495                 /* 0x0000057A 02           */ IL_013A: ldarg.0496                 /* 0x0000057B 17           */ IL_013B: ldc.i4.1497                 /* 0x0000057C 7D05000004   */ IL_013C: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'498                 /* 0x00000581 17           */ IL_0141: ldc.i4.1499                 /* 0x00000582 0A           */ IL_0142: stloc.0500                 /* 0x00000583 DE46         */ IL_0143: leave.s   IL_018B501 502                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */503                 /* 0x00000585 02           */ IL_0145: ldarg.0504                 /* 0x00000586 1FFC         */ IL_0146: ldc.i4.s  -4505                 /* 0x00000588 7D05000004   */ IL_0148: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'506                 /* (53,17)-(53,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */507                 /* 0x0000058D 00           */ IL_014D: nop508                 /* 0x0000058E 02           */ IL_014E: ldarg.0509                 /* 0x0000058F 14           */ IL_014F: ldnull510                 /* 0x00000590 7D0D000004   */ IL_0150: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6'511 512                 /* (50,38)-(50,40) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */513                 /* 0x00000595 02           */ IL_0155: ldarg.0514                 /* 0x00000596 7B0C000004   */ IL_0156: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'515                 /* 0x0000059B 6F1100000A   */ IL_015B: callvirt  instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()516                 /* 0x000005A0 2DBA         */ IL_0160: brtrue.s  IL_011C517 518                 /* 0x000005A2 02           */ IL_0162: ldarg.0519                 /* 0x000005A3 280D000006   */ IL_0163: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally2'()520                 /* 0x000005A8 00           */ IL_0168: nop521                 /* 0x000005A9 02           */ IL_0169: ldarg.0522                 /* 0x000005AA 14           */ IL_016A: ldnull523                 /* 0x000005AB 7D0C000004   */ IL_016B: stfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'524                 /* (54,13)-(54,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */525                 /* 0x000005B0 00           */ IL_0170: nop526                 /* 0x000005B1 02           */ IL_0171: ldarg.0527                 /* 0x000005B2 280C000006   */ IL_0172: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally1'()528                 /* 0x000005B7 00           */ IL_0177: nop529                 /* 0x000005B8 02           */ IL_0178: ldarg.0530                 /* 0x000005B9 14           */ IL_0179: ldnull531                 /* 0x000005BA 7D08000004   */ IL_017A: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'532                 /* (55,9)-(55,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */533                 /* 0x000005BF 16           */ IL_017F: ldc.i4.0534                 /* 0x000005C0 0A           */ IL_0180: stloc.0535                 /* 0x000005C1 DE08         */ IL_0181: leave.s   IL_018B536             } // end .try537             fault538             {539                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */540                 /* 0x000005C3 02           */ IL_0183: ldarg.0541                 /* 0x000005C4 280A000006   */ IL_0184: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::System.IDisposable.Dispose()542                 /* 0x000005C9 00           */ IL_0189: nop543                 /* 0x000005CA DC           */ IL_018A: endfinally544             } // end handler545 546             /* 0x000005CB 06           */ IL_018B: ldloc.0547             /* 0x000005CC 2A           */ IL_018C: ret548         } // end of method '<CreateCollection>d__1'::MoveNext549 550         // Token: 0x0600000C RID: 12 RVA: 0x00002404 File Offset: 0x00000604551         .method private hidebysig 552             instance void '<>m__Finally1' () cil managed 553         {554             // Header Size: 1 byte555             // Code Size: 38 (0x26) bytes556             .maxstack 8557 558             /* 0x00000605 02           */ IL_0000: ldarg.0559             /* 0x00000606 15           */ IL_0001: ldc.i4.m1560             /* 0x00000607 7D05000004   */ IL_0002: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'561             /* 0x0000060C 02           */ IL_0007: ldarg.0562             /* 0x0000060D 7B08000004   */ IL_0008: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'563             /* 0x00000612 7B02000004   */ IL_000D: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection564             /* 0x00000617 2C11         */ IL_0012: brfalse.s IL_0025565 566             /* 0x00000619 02           */ IL_0014: ldarg.0567             /* 0x0000061A 7B08000004   */ IL_0015: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1'568             /* 0x0000061F 7B02000004   */ IL_001A: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection569             /* 0x00000624 6F1000000A   */ IL_001F: callvirt  instance void [mscorlib]System.IDisposable::Dispose()570             /* 0x00000629 00           */ IL_0024: nop571 572             /* 0x0000062A 2A           */ IL_0025: ret573         } // end of method '<CreateCollection>d__1'::'<>m__Finally1'574 575         // Token: 0x0600000D RID: 13 RVA: 0x0000242B File Offset: 0x0000062B576         .method private hidebysig 577             instance void '<>m__Finally2' () cil managed 578         {579             // Header Size: 1 byte580             // Code Size: 29 (0x1D) bytes581             .maxstack 8582 583             /* 0x0000062C 02           */ IL_0000: ldarg.0584             /* 0x0000062D 1FFD         */ IL_0001: ldc.i4.s  -3585             /* 0x0000062F 7D05000004   */ IL_0003: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'586             /* 0x00000634 02           */ IL_0008: ldarg.0587             /* 0x00000635 7B0C000004   */ IL_0009: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'588             /* 0x0000063A 2C0C         */ IL_000E: brfalse.s IL_001C589 590             /* 0x0000063C 02           */ IL_0010: ldarg.0591             /* 0x0000063D 7B0C000004   */ IL_0011: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5'592             /* 0x00000642 6F1000000A   */ IL_0016: callvirt  instance void [mscorlib]System.IDisposable::Dispose()593             /* 0x00000647 00           */ IL_001B: nop594 595             /* 0x00000648 2A           */ IL_001C: ret596         } // end of method '<CreateCollection>d__1'::'<>m__Finally2'597 598         // Token: 0x0600000E RID: 14 RVA: 0x00002449 File Offset: 0x00000649599         .method private final hidebysig specialname newslot virtual 600             instance string 'System.Collections.Generic.IEnumerator<System.String>.get_Current' () cil managed 601         {602             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (603                 01 00 00 00604             )605             .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current()606             // Header Size: 1 byte607             // Code Size: 7 (0x7) bytes608             .maxstack 8609 610             /* 0x0000064A 02           */ IL_0000: ldarg.0611             /* 0x0000064B 7B06000004   */ IL_0001: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current'612             /* 0x00000650 2A           */ IL_0006: ret613         } // end of method '<CreateCollection>d__1'::'System.Collections.Generic.IEnumerator<System.String>.get_Current'614 615         // Token: 0x0600000F RID: 15 RVA: 0x00002451 File Offset: 0x00000651616         .method private final hidebysig newslot virtual 617             instance void System.Collections.IEnumerator.Reset () cil managed 618         {619             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (620                 01 00 00 00621             )622             .override method instance void [mscorlib]System.Collections.IEnumerator::Reset()623             // Header Size: 1 byte624             // Code Size: 6 (0x6) bytes625             .maxstack 8626 627             /* 0x00000652 732B00000A   */ IL_0000: newobj    instance void [mscorlib]System.NotSupportedException::.ctor()628             /* 0x00000657 7A           */ IL_0005: throw629         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerator.Reset630 631         // Token: 0x06000010 RID: 16 RVA: 0x00002458 File Offset: 0x00000658632         .method private final hidebysig specialname newslot virtual 633             instance object System.Collections.IEnumerator.get_Current () cil managed 634         {635             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (636                 01 00 00 00637             )638             .override method instance object [mscorlib]System.Collections.IEnumerator::get_Current()639             // Header Size: 1 byte640             // Code Size: 7 (0x7) bytes641             .maxstack 8642 643             /* 0x00000659 02           */ IL_0000: ldarg.0644             /* 0x0000065A 7B06000004   */ IL_0001: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current'645             /* 0x0000065F 2A           */ IL_0006: ret646         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerator.get_Current647 648         // Token: 0x06000011 RID: 17 RVA: 0x00002460 File Offset: 0x00000660649         .method private final hidebysig newslot virtual 650             instance class [mscorlib]System.Collections.Generic.IEnumerator`1<string> 'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator' () cil managed 651         {652             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (653                 01 00 00 00654             )655             .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator()656             // Header Size: 12 bytes657             // Code Size: 48 (0x30) bytes658             // LocalVarSig Token: 0x11000005 RID: 5659             .maxstack 2660             .locals init (661                 [0] class ConsoleApp1.Program/'<CreateCollection>d__1'662             )663 664             /* 0x0000066C 02           */ IL_0000: ldarg.0665             /* 0x0000066D 7B05000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'666             /* 0x00000672 1FFE         */ IL_0006: ldc.i4.s  -2667             /* 0x00000674 331D         */ IL_0008: bne.un.s  IL_0027668 669             /* 0x00000676 02           */ IL_000A: ldarg.0670             /* 0x00000677 7B07000004   */ IL_000B: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>l__initialThreadId'671             /* 0x0000067C 282200000A   */ IL_0010: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread()672             /* 0x00000681 6F2300000A   */ IL_0015: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId()673             /* 0x00000686 330B         */ IL_001A: bne.un.s  IL_0027674 675             /* 0x00000688 02           */ IL_001C: ldarg.0676             /* 0x00000689 16           */ IL_001D: ldc.i4.0677             /* 0x0000068A 7D05000004   */ IL_001E: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state'678             /* 0x0000068F 02           */ IL_0023: ldarg.0679             /* 0x00000690 0A           */ IL_0024: stloc.0680             /* 0x00000691 2B07         */ IL_0025: br.s      IL_002E681 682             /* 0x00000693 16           */ IL_0027: ldc.i4.0683             /* 0x00000694 7309000006   */ IL_0028: newobj    instance void ConsoleApp1.Program/'<CreateCollection>d__1'::.ctor(int32)684             /* 0x00000699 0A           */ IL_002D: stloc.0685 686             /* 0x0000069A 06           */ IL_002E: ldloc.0687             /* 0x0000069B 2A           */ IL_002F: ret688         } // end of method '<CreateCollection>d__1'::'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator'689 690         // Token: 0x06000012 RID: 18 RVA: 0x0000249C File Offset: 0x0000069C691         .method private final hidebysig newslot virtual 692             instance class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () cil managed 693         {694             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (695                 01 00 00 00696             )697             .override method instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator()698             // Header Size: 1 byte699             // Code Size: 7 (0x7) bytes700             .maxstack 8701 702             /* 0x0000069D 02           */ IL_0000: ldarg.0703             /* 0x0000069E 2811000006   */ IL_0001: call      instance class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator'()704             /* 0x000006A3 2A           */ IL_0006: ret705         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerable.GetEnumerator706 707         // Properties708         // Token: 0x17000001 RID: 1709         .property instance string 'System.Collections.Generic.IEnumerator<System.String>.Current'()710         {711             // Token: 0x0600000E RID: 14 RVA: 0x00002449 File Offset: 0x00000649712             .get instance string ConsoleApp1.Program/'<CreateCollection>d__1'::'System.Collections.Generic.IEnumerator<System.String>.get_Current'()713         }714         // Token: 0x17000002 RID: 2715         .property instance object System.Collections.IEnumerator.Current()716         {717             // Token: 0x06000010 RID: 16 RVA: 0x00002458 File Offset: 0x00000658718             .get instance object ConsoleApp1.Program/'<CreateCollection>d__1'::System.Collections.IEnumerator.get_Current()719         }720 721     } // end of class <CreateCollection>d__1722 723 724     // Fields725     // Token: 0x04000001 RID: 1726     .field private static initonly object globalLock727 728     // Methods729     // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250730     .method private hidebysig static 
731         void Main (732             string[] args733         ) cil managed 734     {735         // Header Size: 12 bytes736         // Code Size: 67 (0x43) bytes737         // LocalVarSig Token: 0x11000001 RID: 1738         .maxstack 2739         .entrypoint740         .locals init (741             [0] class [mscorlib]System.Collections.Generic.IEnumerable`1<string> coll,742             [1] class [mscorlib]System.Collections.Generic.IEnumerator`1<string>,743             [2] string str744         )745 746         /* (13,9)-(13,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */747         /* 0x0000025C 00           */ IL_0000: nop748         /* (14,13)-(14,59) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */749         /* 0x0000025D 2802000006   */ IL_0001: call      class [mscorlib]System.Collections.Generic.IEnumerable`1<string> ConsoleApp1.Program::CreateCollection()750         /* 0x00000262 0A           */ IL_0006: stloc.0751         /* (15,13)-(15,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */752         /* 0x00000263 00           */ IL_0007: nop753         /* (16,17)-(16,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */754         /* 0x00000264 00           */ IL_0008: nop755         /* (16,40)-(16,44) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */756         /* 0x00000265 06           */ IL_0009: ldloc.0757         /* 0x00000266 6F1500000A   */ IL_000A: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator()758         /* 0x0000026B 0B           */ IL_000F: stloc.1759         .try760         {761             /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */762             /* 0x0000026C 2B1A         */ IL_0010: br.s      IL_002C763             // loop start (head: IL_002C)764                 /* (16,26)-(16,36) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */765                 /* 0x0000026E 07           */ IL_0012: ldloc.1766                 /* 0x0000026F 6F1200000A   */ IL_0013: callvirt  instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current()767                 /* 0x00000274 0C           */ IL_0018: stloc.2768                 /* (17,17)-(17,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */769                 /* 0x00000275 00           */ IL_0019: nop770                 /* (18,21)-(18,55) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */771                 /* 0x00000276 7201000070   */ IL_001A: ldstr     "read: "772                 /* 0x0000027B 08           */ IL_001F: ldloc.2773                 /* 0x0000027C 281800000A   */ IL_0020: call      string [mscorlib]System.String::Concat(string, string)774                 /* 0x00000281 281900000A   */ IL_0025: call      void [mscorlib]System.Console::WriteLine(string)775                 /* 0x00000286 00           */ IL_002A: nop776                 /* (19,17)-(19,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */777                 /* 0x00000287 00           */ IL_002B: nop778 779                 /* (16,37)-(16,39) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */780                 /* 0x00000288 07           */ IL_002C: ldloc.1781                 /* 0x00000289 6F1100000A   */ IL_002D: callvirt  instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()782                 /* 0x0000028E 2DDE         */ IL_0032: brtrue.s  IL_0012783             // end loop784 785             /* 0x00000290 DE0B         */ IL_0034: leave.s   IL_0041786         } // end .try787         finally788         {789             /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */790             /* 0x00000292 07           */ IL_0036: ldloc.1791             /* 0x00000293 2C07         */ IL_0037: brfalse.s IL_0040792 793             /* 0x00000295 07           */ IL_0039: ldloc.1794             /* 0x00000296 6F1000000A   */ IL_003A: callvirt  instance void [mscorlib]System.IDisposable::Dispose()795             /* 0x0000029B 00           */ IL_003F: nop796 797             /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */798             /* 0x0000029C DC           */ IL_0040: endfinally799         } // end handler800 801         /* (20,13)-(20,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */802         /* 0x0000029D 00           */ IL_0041: nop803         /* (21,9)-(21,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */804         /* 0x0000029E 2A           */ IL_0042: ret805     } // end of method Program::Main806 807     // Token: 0x06000002 RID: 2 RVA: 0x000020B0 File Offset: 0x000002B0808     .method private hidebysig static 
809         class [mscorlib]System.Collections.Generic.IEnumerable`1<string> CreateCollection () cil managed 810     {811         // Header Size: 1 byte812         // Code Size: 8 (0x8) bytes813         .maxstack 8814 815         /* 0x000002B1 1FFE         */ IL_0000: ldc.i4.s  -2816         /* 0x000002B3 7309000006   */ IL_0002: newobj    instance void ConsoleApp1.Program/'<CreateCollection>d__1'::.ctor(int32)817         /* 0x000002B8 2A           */ IL_0007: ret818     } // end of method Program::CreateCollection819 820     // Token: 0x06000003 RID: 3 RVA: 0x000020B9 File Offset: 0x000002B9821     .method public hidebysig specialname rtspecialname 822         instance void .ctor () cil managed 823     {824         // Header Size: 1 byte825         // Code Size: 8 (0x8) bytes826         .maxstack 8827 828         /* 0x000002BA 02           */ IL_0000: ldarg.0829         /* 0x000002BB 281A00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor()830         /* 0x000002C0 00           */ IL_0006: nop831         /* 0x000002C1 2A           */ IL_0007: ret832     } // end of method Program::.ctor833 834     // Token: 0x06000004 RID: 4 RVA: 0x000020C2 File Offset: 0x000002C2835     .method private hidebysig specialname rtspecialname static 
836         void .cctor () cil managed 837     {838         // Header Size: 1 byte839         // Code Size: 11 (0xB) bytes840         .maxstack 8841 842         /* (58,9)-(58,66) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */843         /* 0x000002C3 731A00000A   */ IL_0000: newobj    instance void [mscorlib]System.Object::.ctor()844         /* 0x000002C8 8001000004   */ IL_0005: stsfld    object ConsoleApp1.Program::globalLock845         /* 0x000002CD 2A           */ IL_000A: ret846     } // end of method Program::.cctor847 848 } // end of class ConsoleApp1.Program

View Code

为了清晰显示其逻辑,对应IL,重写其逻辑如下:

  1 class Program  2 {  3     static void Main(string[] args)  4     {  5         IEnumerable<string> coll = CreateCollection();  6         IEnumerator<string> enumerator = coll.GetEnumerator();  7         string str = null;  8   9         try 10         { 11             goto IL_002C; 12         IL_0012: 13             str = enumerator.Current; 14  15             Console.WriteLine(string.Concat("read: ", str)); 16  17         IL_002C: 18             if (enumerator.MoveNext()) 19             { 20                 goto IL_0012; 21             } 22         } 23         finally 24         { 25             if (enumerator != null) 26             { 27                 enumerator.Dispose(); 28             } 29         } 30     } 31  32     private static IEnumerable<string> CreateCollection() 33     { 34         return new CreateCollection_1(-2); 35     } 
 36  37     private static readonly object globalLock = new object(); 38  39     private class DisplayClass1_0 40     { 41         public BlockingCollection<string> collection; 42  43         public DisplayClass1_0() 44         { 45  46         } 47  48         public void CreateCollection() 49         { 50             object loc0 = Program.globalLock; 51             bool loc1 = false; 52             int i = 0; 53             string value; 54             bool arg4; 55  56             try 57             { 58                 Monitor.Enter(loc0, ref loc1); 59  60                 goto IL_0074; 61             IL_0017: 62                 Thread.Sleep(100); 63                 value = string.Format("value: {0}", i); 64                 Console.WriteLine(string.Concat("write: ", value)); 65                 collection.Add(string.Format("value: {0}", i)); 66                 Console.WriteLine(string.Concat("end write: ", value)); 67                 i = i + 1; 68             IL_0074: 69                 arg4 = i < 10; 70                 if (arg4) 71                 { 72                     goto IL_0017; 73                 } 74             } 75             finally 76             { 77                 if (loc1) 78                 { 79                     Monitor.Exit(loc0); 80                 } 81             } 82         } 83     } 84  85     private class DisplayClass1_1 86     { 87         public Exception err; 88         public DisplayClass1_0 locals1; 89  90         public DisplayClass1_1() { } 91  92         public void CreateCollection(Task task) 93         { 94             locals1.collection.CompleteAdding(); 95             err = task.Exception; 96         } 97     } 98  99     private class CreateCollection_1100         : IEnumerable<string>,101         IEnumerable,102         IEnumerator<string>,103         IEnumerator,104         IDisposable105     {106         private int state;107         private string current;108         private int initialThreadId;109 110         private DisplayClass1_0 f8__1;111 112         private object s__2;113         private bool s__3;114 115         private DisplayClass1_1 f8__4;116 117         private IEnumerator<string> s__5;118 119         private string item5__6;120 121         public CreateCollection_1(int state)122         {123             this.state = state;124             this.initialThreadId125                 = Thread.CurrentThread.ManagedThreadId;126         }127 128         void IDisposable.Dispose()129         {130             int loc_0 = this.state;131             if (loc_0 + 4 <= 1)132             {133                 goto IL_0016;134             }135             if (loc_0 == 1)136             {137                 return;138             }139 140         IL_0016:141             ;142 143             try144             {145                 if (loc_0 == -4)146                 {147                     goto IL_0024;148                 }149 150                 if (loc_0 == 1)151                 {152                     goto IL_0024;153                 }154                 return;155 156             IL_0024:;157 158                 try159                 {160                 }161                 finally162                 {163                     this.m__Finally2();164                 }165             }166             finally167             {168                 this.m__Finally1();169             }170         }171 172         bool IEnumerator.MoveNext()173         {174             bool loc_0;175             int loc_1;176 177             try178             {179                 loc_1 = this.state;180                 if (loc_1 == 0)181                 {182                     goto IL_0012;183                 }184                 if (loc_1 == 1)185                 {186                     goto IL_0014;187                 }188                 goto IL_0019;189 190             IL_0012:;191                 goto IL_0020;192             IL_0014:;193                 goto IL_0145;194             IL_0019:;195                 return false;196             IL_0020:;197                 this.state = -1;198                 this.f8__1 = new DisplayClass1_0();199                 this.f8__1.collection = new BlockingCollection<string>();200                 this.state = -3;201                 this.s__2 = Program.globalLock;202                 this.s__3 = false;203 204                 try205                 {206                     Monitor.Enter(this.s__2, ref this.s__3);207 208                     this.f8__4 = new DisplayClass1_1();209                     this.f8__4.locals1 = this.f8__1;210                     this.f8__4.err = null;211 212                     Task.Factory.StartNew(new Action(this.f8__4.locals1.CreateCollection))213                         .ContinueWith(new Action<Task>(this.f8__4.CreateCollection));214 215                     this.f8__4 = null;216                 }217                 finally218                 {219                     if (this.s__3)220                     {221                         Monitor.Exit(this.s__2);222                     }223                 }224 225                 this.s__2 = null;226 227                 this.s__5 =228                     this.f8__1229                     .collection230                     .GetConsumingEnumerable()231                     .GetEnumerator();232 233                 this.state = -4;234 235                 goto IL_0155;236             IL_011C:237                 this.item5__6 = this.s__5.Current;238 239                 this.current = this.item5__6;240 241                 this.state = 1;242                 loc_0 = true;243 244                 return loc_0;245 246             IL_0145:247                 this.state = -4;248                 this.item5__6 = null;249             IL_0155:250                 if (this.s__5.MoveNext())251                 {252                     goto IL_011C;253                 }254 255                 this.m__Finally2();256                 this.s__5 = null;257 258                 this.m__Finally1();259 260                 this.f8__1 = null;261 262                 loc_0 = false;263                 return loc_0;264             }265             finally266             {267                 ((IDisposable)this).Dispose();268             }269         }270 271         private void m__Finally2()272         {273             this.state = -3;274             if (this.s__5 == null)275             {276                 return;277             }278 279             this.s__5.Dispose();280         }281 282         private void m__Finally1()283         {284             this.state = -1;285 286             if (this.f8__1 == null || this.f8__1.collection == null)287             {288                 return;289             }290             this.f8__1.collection.Dispose();291         }292 293         string IEnumerator<string>.Current294         {295             get296             {297                 return this.current;298             }299         }300 301         void IEnumerator.Reset()302         {303             throw new NotSupportedException();304         }305 306         object IEnumerator.Current307         {308             get309             {310                 return this.current;311             }312         }313 314         IEnumerator<string> IEnumerable<string>.GetEnumerator()315         {316             CreateCollection_1 createCollection = null;317             if (this.state != -2)318             {319                 goto IL_0027;320             }321 322             if (this.initialThreadId != Thread.CurrentThread.ManagedThreadId)323             {324                 goto IL_0027;325             }326 327             this.state = 0;328             createCollection = this;329             goto IL_002E;330         IL_0027:;331             createCollection = new CreateCollection_1(0);332         IL_002E:333             return createCollection;334         }335 336         IEnumerator IEnumerable.GetEnumerator()337         {338             return ((IEnumerable<string>)this).GetEnumerator();339         }340     }341 }

为了可以使之可以编译通过,修改了不合法的类名、变量名等,编译并运行的结果和源码一样,接下来就是仔细看其实现逻辑了。

对于Main方法,其逻辑即为通过方法 CreateCollection() 获取一个IEnumerable<string>对象,没啥好看的。

里查看 CreateCollection() 方法的实现,发现我们的逻辑都不见了,取而代之的是返回了一个 CreateCollection_1 对象实例,这就是我们的迭代器了。

1 private static IEnumerable<string> CreateCollection()2 {3     return new CreateCollection_1(-2);4 }

那么 CreateCollection_1 类都做了什么呢?

我们发现,该类分别实现了 IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable 共五个接口,并且创建了两个新的内部类,DisplayClass1_0 和 DisplayClass1_1,分别对应我们 Task 启动的线程逻辑。

我们看 CreateCollection_1.MoveNext() 方法和 DisplayClass1_0.CreateCollection()方法,发现两个方法均加了锁,而且 CreateCollection_1 类有线程校验。

但是我们的要求是 CreateCollection() 方法内代码同步,既然编译器会自动添加锁,那么将代码改为如下形式会怎么样呢?

class Program
{public static void Main(string[] args)
    {
        Task.Factory.StartNew(() =>{
            Console.WriteLine($"start ----------> {Thread.CurrentThread.ManagedThreadId}");
            IEnumerable<string> coll = CreateCollection();foreach (string str in coll)
            {
                Console.WriteLine($"read [{Thread.CurrentThread.ManagedThreadId}]: {str}");
            }
        });

        Task.Factory.StartNew(() =>{
            Console.WriteLine($"start ----------> {Thread.CurrentThread.ManagedThreadId}");
            IEnumerable<string> coll = CreateCollection();foreach (string str in coll)
            {
                Console.WriteLine($"read [{Thread.CurrentThread.ManagedThreadId}]: {str}");
            }
        });

        Console.ReadKey();
    }private static IEnumerable<string> CreateCollection()
    {using (BlockingCollection<string> collection = new BlockingCollection<string>())
        {lock (globalLock)
            {
                Exception err = null;
                Task.Factory.StartNew(() =>{
                    Console.WriteLine("start new ...");for (int i = 0; i < 10; i++)
                    {
                        Thread.Sleep(100);string value = $"value: {i}";
                        Console.WriteLine($"[{Thread.CurrentThread.ManagedThreadId}] write: {value}");
                        collection.Add($"value: {i}");
                        Console.WriteLine($"[{Thread.CurrentThread.ManagedThreadId}] end write: {value}");
                    }
                }).ContinueWith((task) =>{
                    collection.CompleteAdding();
                    err = task.Exception;
                });foreach (string item in collection.GetConsumingEnumerable())
                {yield return item;
                }
            }
        }
    }private static readonly object globalLock = new object();
}

运行结果如下:

结果看起来是正确的,那么靠谱吗?还是到IL里面查找答案:

   1 // Token: 0x02000002 RID: 2   2 .class private auto ansi beforefieldinit ConsoleApp1.Program   3     extends [mscorlib]System.Object   4 {   5     // Nested Types   6     // Token: 0x02000003 RID: 3   7     .class nested private auto ansi sealed serializable beforefieldinit '<>c'   8         extends [mscorlib]System.Object   9     {  10         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (  11             01 00 00 00  12         )  13         // Fields  14         // Token: 0x04000002 RID: 2  15         .field public static initonly class ConsoleApp1.Program/'<>c' '<>9'  16         // Token: 0x04000003 RID: 3  17         .field public static class [mscorlib]System.Action '<>9__0_0'  18         // Token: 0x04000004 RID: 4  19         .field public static class [mscorlib]System.Action '<>9__0_1'  20   21         // Methods  22         // Token: 0x06000005 RID: 5 RVA: 0x000020D6 File Offset: 0x000002D6  23         .method private hidebysig specialname rtspecialname static 
  24             void .cctor () cil managed   25         {  26             // Header Size: 1 byte  27             // Code Size: 11 (0xB) bytes  28             .maxstack 8  29   30             /* 0x000002D7 7306000006   */ IL_0000: newobj    instance void ConsoleApp1.Program/'<>c'::.ctor()  31             /* 0x000002DC 8002000004   */ IL_0005: stsfld    class ConsoleApp1.Program/'<>c' ConsoleApp1.Program/'<>c'::'<>9'  32             /* 0x000002E1 2A           */ IL_000A: ret  33         } // end of method '<>c'::.cctor  34   35         // Token: 0x06000006 RID: 6 RVA: 0x000020E2 File Offset: 0x000002E2  36         .method public hidebysig specialname rtspecialname   37             instance void .ctor () cil managed   38         {  39             // Header Size: 1 byte  40             // Code Size: 8 (0x8) bytes  41             .maxstack 8  42   43             /* 0x000002E3 02           */ IL_0000: ldarg.0  44             /* 0x000002E4 281C00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor()  45             /* 0x000002E9 00           */ IL_0006: nop  46             /* 0x000002EA 2A           */ IL_0007: ret  47         } // end of method '<>c'::.ctor  48   49         // Token: 0x06000007 RID: 7 RVA: 0x000020EC File Offset: 0x000002EC  50         .method assembly hidebysig   51             instance void '<Main>b__0_0' () cil managed   52         {  53             // Header Size: 12 bytes  54             // Code Size: 111 (0x6F) bytes  55             // LocalVarSig Token: 0x11000001 RID: 1  56             .maxstack 3  57             .locals init (  58                 [0] class [mscorlib]System.Collections.Generic.IEnumerable`1<string> coll,  59                 [1] class [mscorlib]System.Collections.Generic.IEnumerator`1<string>,  60                 [2] string str  61             )  62   63             /* (14,13)-(14,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  64             /* 0x000002F8 00           */ IL_0000: nop  65             /* (15,17)-(15,96) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  66             /* 0x000002F9 7201000070   */ IL_0001: ldstr     "start ----------> {0}"  67             /* 0x000002FE 281D00000A   */ IL_0006: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread()  68             /* 0x00000303 6F1E00000A   */ IL_000B: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId()  69             /* 0x00000308 8C20000001   */ IL_0010: box       [mscorlib]System.Int32  70             /* 0x0000030D 281F00000A   */ IL_0015: call      string [mscorlib]System.String::Format(string, object)  71             /* 0x00000312 282000000A   */ IL_001A: call      void [mscorlib]System.Console::WriteLine(string)  72             /* 0x00000317 00           */ IL_001F: nop  73             /* (16,17)-(16,63) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  74             /* 0x00000318 2802000006   */ IL_0020: call      class [mscorlib]System.Collections.Generic.IEnumerable`1<string> ConsoleApp1.Program::CreateCollection()  75             /* 0x0000031D 0A           */ IL_0025: stloc.0  76             /* (18,17)-(18,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  77             /* 0x0000031E 00           */ IL_0026: nop  78             /* (18,40)-(18,44) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  79             /* 0x0000031F 06           */ IL_0027: ldloc.0  80             /* 0x00000320 6F1500000A   */ IL_0028: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator()  81             /* 0x00000325 0B           */ IL_002D: stloc.1  82             .try  83             {  84                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  85                 /* 0x00000326 2B29         */ IL_002E: br.s      IL_0059  86                 // loop start (head: IL_0059)  87                     /* (18,26)-(18,36) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  88                     /* 0x00000328 07           */ IL_0030: ldloc.1  89                     /* 0x00000329 6F1200000A   */ IL_0031: callvirt  instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current()  90                     /* 0x0000032E 0C           */ IL_0036: stloc.2  91                     /* (19,17)-(19,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  92                     /* 0x0000032F 00           */ IL_0037: nop  93                     /* (20,21)-(20,96) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */  94                     /* 0x00000330 722D000070   */ IL_0038: ldstr     "read [{0}]: {1}"  95                     /* 0x00000335 281D00000A   */ IL_003D: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread()  96                     /* 0x0000033A 6F1E00000A   */ IL_0042: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId()  97                     /* 0x0000033F 8C20000001   */ IL_0047: box       [mscorlib]System.Int32  98                     /* 0x00000344 08           */ IL_004C: ldloc.2  99                     /* 0x00000345 282100000A   */ IL_004D: call      string [mscorlib]System.String::Format(string, object, object) 100                     /* 0x0000034A 282000000A   */ IL_0052: call      void [mscorlib]System.Console::WriteLine(string) 101                     /* 0x0000034F 00           */ IL_0057: nop 102                     /* (21,17)-(21,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 103                     /* 0x00000350 00           */ IL_0058: nop 104  105                     /* (18,37)-(18,39) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 106                     /* 0x00000351 07           */ IL_0059: ldloc.1 107                     /* 0x00000352 6F1100000A   */ IL_005A: callvirt  instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() 108                     /* 0x00000357 2DCF         */ IL_005F: brtrue.s  IL_0030 109                 // end loop 110  111                 /* 0x00000359 DE0B         */ IL_0061: leave.s   IL_006E 112             } // end .try 113             finally 114             { 115                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 116                 /* 0x0000035B 07           */ IL_0063: ldloc.1 117                 /* 0x0000035C 2C07         */ IL_0064: brfalse.s IL_006D 118  119                 /* 0x0000035E 07           */ IL_0066: ldloc.1 120                 /* 0x0000035F 6F1000000A   */ IL_0067: callvirt  instance void [mscorlib]System.IDisposable::Dispose() 121                 /* 0x00000364 00           */ IL_006C: nop 122  123                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 124                 /* 0x00000365 DC           */ IL_006D: endfinally 125             } // end handler 126  127             /* (22,13)-(22,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 128             /* 0x00000366 2A           */ IL_006E: ret 129         } // end of method '<>c'::'<Main>b__0_0' 130  131         // Token: 0x06000008 RID: 8 RVA: 0x00002178 File Offset: 0x00000378 132         .method assembly hidebysig  133             instance void '<Main>b__0_1' () cil managed  134         { 135             // Header Size: 12 bytes 136             // Code Size: 111 (0x6F) bytes 137             // LocalVarSig Token: 0x11000001 RID: 1 138             .maxstack 3 139             .locals init ( 140                 [0] class [mscorlib]System.Collections.Generic.IEnumerable`1<string> coll, 141                 [1] class [mscorlib]System.Collections.Generic.IEnumerator`1<string>, 142                 [2] string str 143             ) 144  145             /* (25,13)-(25,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 146             /* 0x00000384 00           */ IL_0000: nop 147             /* (26,17)-(26,96) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 148             /* 0x00000385 7201000070   */ IL_0001: ldstr     "start ----------> {0}" 149             /* 0x0000038A 281D00000A   */ IL_0006: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 150             /* 0x0000038F 6F1E00000A   */ IL_000B: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 151             /* 0x00000394 8C20000001   */ IL_0010: box       [mscorlib]System.Int32 152             /* 0x00000399 281F00000A   */ IL_0015: call      string [mscorlib]System.String::Format(string, object) 153             /* 0x0000039E 282000000A   */ IL_001A: call      void [mscorlib]System.Console::WriteLine(string) 154             /* 0x000003A3 00           */ IL_001F: nop 155             /* (27,17)-(27,63) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 156             /* 0x000003A4 2802000006   */ IL_0020: call      class [mscorlib]System.Collections.Generic.IEnumerable`1<string> ConsoleApp1.Program::CreateCollection() 157             /* 0x000003A9 0A           */ IL_0025: stloc.0 158             /* (29,17)-(29,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 159             /* 0x000003AA 00           */ IL_0026: nop 160             /* (29,40)-(29,44) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 161             /* 0x000003AB 06           */ IL_0027: ldloc.0 162             /* 0x000003AC 6F1500000A   */ IL_0028: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator() 163             /* 0x000003B1 0B           */ IL_002D: stloc.1 164             .try 165             { 166                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 167                 /* 0x000003B2 2B29         */ IL_002E: br.s      IL_0059 168                 // loop start (head: IL_0059) 169                     /* (29,26)-(29,36) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 170                     /* 0x000003B4 07           */ IL_0030: ldloc.1 171                     /* 0x000003B5 6F1200000A   */ IL_0031: callvirt  instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current() 172                     /* 0x000003BA 0C           */ IL_0036: stloc.2 173                     /* (30,17)-(30,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 174                     /* 0x000003BB 00           */ IL_0037: nop 175                     /* (31,21)-(31,96) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 176                     /* 0x000003BC 722D000070   */ IL_0038: ldstr     "read [{0}]: {1}" 177                     /* 0x000003C1 281D00000A   */ IL_003D: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 178                     /* 0x000003C6 6F1E00000A   */ IL_0042: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 179                     /* 0x000003CB 8C20000001   */ IL_0047: box       [mscorlib]System.Int32 180                     /* 0x000003D0 08           */ IL_004C: ldloc.2 181                     /* 0x000003D1 282100000A   */ IL_004D: call      string [mscorlib]System.String::Format(string, object, object) 182                     /* 0x000003D6 282000000A   */ IL_0052: call      void [mscorlib]System.Console::WriteLine(string) 183                     /* 0x000003DB 00           */ IL_0057: nop 184                     /* (32,17)-(32,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 185                     /* 0x000003DC 00           */ IL_0058: nop 186  187                     /* (29,37)-(29,39) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 188                     /* 0x000003DD 07           */ IL_0059: ldloc.1 189                     /* 0x000003DE 6F1100000A   */ IL_005A: callvirt  instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() 190                     /* 0x000003E3 2DCF         */ IL_005F: brtrue.s  IL_0030 191                 // end loop 192  193                 /* 0x000003E5 DE0B         */ IL_0061: leave.s   IL_006E 194             } // end .try 195             finally 196             { 197                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 198                 /* 0x000003E7 07           */ IL_0063: ldloc.1 199                 /* 0x000003E8 2C07         */ IL_0064: brfalse.s IL_006D 200  201                 /* 0x000003EA 07           */ IL_0066: ldloc.1 202                 /* 0x000003EB 6F1000000A   */ IL_0067: callvirt  instance void [mscorlib]System.IDisposable::Dispose() 203                 /* 0x000003F0 00           */ IL_006C: nop 204  205                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 206                 /* 0x000003F1 DC           */ IL_006D: endfinally 207             } // end handler 208  209             /* (33,13)-(33,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 210             /* 0x000003F2 2A           */ IL_006E: ret 211         } // end of method '<>c'::'<Main>b__0_1' 212  213     } // end of class <>c 214  215     // Token: 0x02000004 RID: 4 216     .class nested private auto ansi sealed beforefieldinit '<>c__DisplayClass1_0' 217         extends [mscorlib]System.Object 218     { 219         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 220             01 00 00 00 221         ) 222         // Fields 223         // Token: 0x04000005 RID: 5 224         .field public class [System]System.Collections.Concurrent.BlockingCollection`1<string> collection 225  226         // Methods 227         // Token: 0x06000009 RID: 9 RVA: 0x00002204 File Offset: 0x00000404 228         .method public hidebysig specialname rtspecialname  229             instance void .ctor () cil managed  230         { 231             // Header Size: 1 byte 232             // Code Size: 8 (0x8) bytes 233             .maxstack 8 234  235             /* 0x00000405 02           */ IL_0000: ldarg.0 236             /* 0x00000406 281C00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor() 237             /* 0x0000040B 00           */ IL_0006: nop 238             /* 0x0000040C 2A           */ IL_0007: ret 239         } // end of method '<>c__DisplayClass1_0'::.ctor 240  241         // Token: 0x0600000A RID: 10 RVA: 0x00002210 File Offset: 0x00000410 242         .method assembly hidebysig  243             instance void '<CreateCollection>b__0' () cil managed  244         { 245             // Header Size: 12 bytes 246             // Code Size: 152 (0x98) bytes 247             // LocalVarSig Token: 0x11000002 RID: 2 248             .maxstack 3 249             .locals init ( 250                 [0] int32 i, 251                 [1] string 'value', 252                 [2] bool 253             ) 254  255             /* (46,21)-(46,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 256             /* 0x0000041C 00           */ IL_0000: nop 257             /* (47,25)-(47,60) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 258             /* 0x0000041D 724D000070   */ IL_0001: ldstr     "start new ..." 259             /* 0x00000422 282000000A   */ IL_0006: call      void [mscorlib]System.Console::WriteLine(string) 260             /* 0x00000427 00           */ IL_000B: nop 261             /* (48,30)-(48,39) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 262             /* 0x00000428 16           */ IL_000C: ldc.i4.0 263             /* 0x00000429 0A           */ IL_000D: stloc.0 264             /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 265             /* 0x0000042A 2B7B         */ IL_000E: br.s      IL_008B 266             // loop start (head: IL_008B) 267                 /* (49,25)-(49,26) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 268                 /* 0x0000042C 00           */ IL_0010: nop 269                 /* (50,29)-(50,47) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 270                 /* 0x0000042D 1F64         */ IL_0011: ldc.i4.s  100 271                 /* 0x0000042F 282200000A   */ IL_0013: call      void [mscorlib]System.Threading.Thread::Sleep(int32) 272                 /* 0x00000434 00           */ IL_0018: nop 273                 /* (51,29)-(51,58) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 274                 /* 0x00000435 7269000070   */ IL_0019: ldstr     "value: {0}" 275                 /* 0x0000043A 06           */ IL_001E: ldloc.0 276                 /* 0x0000043B 8C20000001   */ IL_001F: box       [mscorlib]System.Int32 277                 /* 0x00000440 281F00000A   */ IL_0024: call      string [mscorlib]System.String::Format(string, object) 278                 /* 0x00000445 0B           */ IL_0029: stloc.1 279                 /* (52,29)-(52,107) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 280                 /* 0x00000446 727F000070   */ IL_002A: ldstr     "[{0}] write: {1}" 281                 /* 0x0000044B 281D00000A   */ IL_002F: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 282                 /* 0x00000450 6F1E00000A   */ IL_0034: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 283                 /* 0x00000455 8C20000001   */ IL_0039: box       [mscorlib]System.Int32 284                 /* 0x0000045A 07           */ IL_003E: ldloc.1 285                 /* 0x0000045B 282100000A   */ IL_003F: call      string [mscorlib]System.String::Format(string, object, object) 286                 /* 0x00000460 282000000A   */ IL_0044: call      void [mscorlib]System.Console::WriteLine(string) 287                 /* 0x00000465 00           */ IL_0049: nop 288                 /* (53,29)-(53,59) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 289                 /* 0x00000466 02           */ IL_004A: ldarg.0 290                 /* 0x00000467 7B05000004   */ IL_004B: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 291                 /* 0x0000046C 7269000070   */ IL_0050: ldstr     "value: {0}" 292                 /* 0x00000471 06           */ IL_0055: ldloc.0 293                 /* 0x00000472 8C20000001   */ IL_0056: box       [mscorlib]System.Int32 294                 /* 0x00000477 281F00000A   */ IL_005B: call      string [mscorlib]System.String::Format(string, object) 295                 /* 0x0000047C 6F2300000A   */ IL_0060: callvirt  instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::Add(!0) 296                 /* 0x00000481 00           */ IL_0065: nop 297                 /* (54,29)-(54,111) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 298                 /* 0x00000482 72A1000070   */ IL_0066: ldstr     "[{0}] end write: {1}" 299                 /* 0x00000487 281D00000A   */ IL_006B: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 300                 /* 0x0000048C 6F1E00000A   */ IL_0070: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 301                 /* 0x00000491 8C20000001   */ IL_0075: box       [mscorlib]System.Int32 302                 /* 0x00000496 07           */ IL_007A: ldloc.1 303                 /* 0x00000497 282100000A   */ IL_007B: call      string [mscorlib]System.String::Format(string, object, object) 304                 /* 0x0000049C 282000000A   */ IL_0080: call      void [mscorlib]System.Console::WriteLine(string) 305                 /* 0x000004A1 00           */ IL_0085: nop 306                 /* (55,25)-(55,26) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 307                 /* 0x000004A2 00           */ IL_0086: nop 308                 /* (48,49)-(48,52) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 309                 /* 0x000004A3 06           */ IL_0087: ldloc.0 310                 /* 0x000004A4 17           */ IL_0088: ldc.i4.1 311                 /* 0x000004A5 58           */ IL_0089: add 312                 /* 0x000004A6 0A           */ IL_008A: stloc.0 313  314                 /* (48,41)-(48,47) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 315                 /* 0x000004A7 06           */ IL_008B: ldloc.0 316                 /* 0x000004A8 1F0A         */ IL_008C: ldc.i4.s  10 317                 /* 0x000004AA FE04         */ IL_008E: clt 318                 /* 0x000004AC 0C           */ IL_0090: stloc.2 319                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 320                 /* 0x000004AD 08           */ IL_0091: ldloc.2 321                 /* 0x000004AE 3A79FFFFFF   */ IL_0092: brtrue    IL_0010 322             // end loop 323  324             /* (56,21)-(56,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 325             /* 0x000004B3 2A           */ IL_0097: ret 326         } // end of method '<>c__DisplayClass1_0'::'<CreateCollection>b__0' 327  328     } // end of class <>c__DisplayClass1_0 329  330     // Token: 0x02000005 RID: 5 331     .class nested private auto ansi sealed beforefieldinit '<>c__DisplayClass1_1' 332         extends [mscorlib]System.Object 333     { 334         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 335             01 00 00 00 336         ) 337         // Fields 338         // Token: 0x04000006 RID: 6 339         .field public class [mscorlib]System.Exception err 340         // Token: 0x04000007 RID: 7 341         .field public class ConsoleApp1.Program/'<>c__DisplayClass1_0' 'CS$<>8__locals1' 342  343         // Methods 344         // Token: 0x0600000B RID: 11 RVA: 0x000022B4 File Offset: 0x000004B4 345         .method public hidebysig specialname rtspecialname  346             instance void .ctor () cil managed  347         { 348             // Header Size: 1 byte 349             // Code Size: 8 (0x8) bytes 350             .maxstack 8 351  352             /* 0x000004B5 02           */ IL_0000: ldarg.0 353             /* 0x000004B6 281C00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor() 354             /* 0x000004BB 00           */ IL_0006: nop 355             /* 0x000004BC 2A           */ IL_0007: ret 356         } // end of method '<>c__DisplayClass1_1'::.ctor 357  358         // Token: 0x0600000C RID: 12 RVA: 0x000022BD File Offset: 0x000004BD 359         .method assembly hidebysig  360             instance void '<CreateCollection>b__1' ( 361                 class [mscorlib]System.Threading.Tasks.Task task 362             ) cil managed  363         { 364             // Header Size: 1 byte 365             // Code Size: 31 (0x1F) bytes 366             .maxstack 8 367  368             /* (57,21)-(57,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 369             /* 0x000004BE 00           */ IL_0000: nop 370             /* (58,25)-(58,53) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 371             /* 0x000004BF 02           */ IL_0001: ldarg.0 372             /* 0x000004C0 7B07000004   */ IL_0002: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1' 373             /* 0x000004C5 7B05000004   */ IL_0007: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 374             /* 0x000004CA 6F2400000A   */ IL_000C: callvirt  instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::CompleteAdding() 375             /* 0x000004CF 00           */ IL_0011: nop 376             /* (59,25)-(59,46) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 377             /* 0x000004D0 02           */ IL_0012: ldarg.0 378             /* 0x000004D1 03           */ IL_0013: ldarg.1 379             /* 0x000004D2 6F2500000A   */ IL_0014: callvirt  instance class [mscorlib]System.AggregateException [mscorlib]System.Threading.Tasks.Task::get_Exception() 380             /* 0x000004D7 7D06000004   */ IL_0019: stfld     class [mscorlib]System.Exception ConsoleApp1.Program/'<>c__DisplayClass1_1'::err 381             /* (60,21)-(60,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 382             /* 0x000004DC 2A           */ IL_001E: ret 383         } // end of method '<>c__DisplayClass1_1'::'<CreateCollection>b__1' 384  385     } // end of class <>c__DisplayClass1_1 386  387     // Token: 0x02000006 RID: 6 388     .class nested private auto ansi sealed beforefieldinit '<CreateCollection>d__1' 389         extends [mscorlib]System.Object 390         implements class [mscorlib]System.Collections.Generic.IEnumerable`1<string>, 391                    [mscorlib]System.Collections.IEnumerable, 392                    class [mscorlib]System.Collections.Generic.IEnumerator`1<string>, 393                    [mscorlib]System.IDisposable, 394                    [mscorlib]System.Collections.IEnumerator 395     { 396         .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 397             01 00 00 00 398         ) 399         // Fields 400         // Token: 0x04000008 RID: 8 401         .field private int32 '<>1__state' 402         // Token: 0x04000009 RID: 9 403         .field private string '<>2__current' 404         // Token: 0x0400000A RID: 10 405         .field private int32 '<>l__initialThreadId' 406         // Token: 0x0400000B RID: 11 407         .field private class ConsoleApp1.Program/'<>c__DisplayClass1_0' '<>8__1' 408         // Token: 0x0400000C RID: 12 409         .field private object '<>s__2' 410         // Token: 0x0400000D RID: 13 411         .field private bool '<>s__3' 412         // Token: 0x0400000E RID: 14 413         .field private class ConsoleApp1.Program/'<>c__DisplayClass1_1' '<>8__4' 414         // Token: 0x0400000F RID: 15 415         .field private class [mscorlib]System.Collections.Generic.IEnumerator`1<string> '<>s__5' 416         // Token: 0x04000010 RID: 16 417         .field private string '<item>5__6' 418  419         // Methods 420         // Token: 0x0600000D RID: 13 RVA: 0x000022DD File Offset: 0x000004DD 421         .method public hidebysig specialname rtspecialname  422             instance void .ctor ( 423                 int32 '<>1__state' 424             ) cil managed  425         { 426             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 427                 01 00 00 00 428             ) 429             // Header Size: 1 byte 430             // Code Size: 31 (0x1F) bytes 431             .maxstack 8 432  433             /* 0x000004DE 02           */ IL_0000: ldarg.0 434             /* 0x000004DF 281C00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor() 435             /* 0x000004E4 00           */ IL_0006: nop 436             /* 0x000004E5 02           */ IL_0007: ldarg.0 437             /* 0x000004E6 03           */ IL_0008: ldarg.1 438             /* 0x000004E7 7D08000004   */ IL_0009: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 439             /* 0x000004EC 02           */ IL_000E: ldarg.0 440             /* 0x000004ED 281D00000A   */ IL_000F: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 441             /* 0x000004F2 6F1E00000A   */ IL_0014: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 442             /* 0x000004F7 7D0A000004   */ IL_0019: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>l__initialThreadId' 443             /* 0x000004FC 2A           */ IL_001E: ret 444         } // end of method '<CreateCollection>d__1'::.ctor 445  446         // Token: 0x0600000E RID: 14 RVA: 0x00002300 File Offset: 0x00000500 447         .method private final hidebysig newslot virtual  448             instance void System.IDisposable.Dispose () cil managed  449         { 450             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 451                 01 00 00 00 452             ) 453             .override method instance void [mscorlib]System.IDisposable::Dispose() 454             // Header Size: 12 bytes 455             // Code Size: 87 (0x57) bytes 456             // LocalVarSig Token: 0x11000003 RID: 3 457             .maxstack 2 458             .locals init ( 459                 [0] int32 460             ) 461  462             /* 0x0000050C 02           */ IL_0000: ldarg.0 463             /* 0x0000050D 7B08000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 464             /* 0x00000512 0A           */ IL_0006: stloc.0 465             /* 0x00000513 06           */ IL_0007: ldloc.0 466             /* 0x00000514 1FFB         */ IL_0008: ldc.i4.s  -5 467             /* 0x00000516 59           */ IL_000A: sub 468             /* 0x00000517 18           */ IL_000B: ldc.i4.2 469             /* 0x00000518 3608         */ IL_000C: ble.un.s  IL_0016 470  471             /* 0x0000051A 2B00         */ IL_000E: br.s      IL_0010 472  473             /* 0x0000051C 06           */ IL_0010: ldloc.0 474             /* 0x0000051D 17           */ IL_0011: ldc.i4.1 475             /* 0x0000051E 2E02         */ IL_0012: beq.s     IL_0016 476  477             /* 0x00000520 2B40         */ IL_0014: br.s      IL_0056 478  479             /* 0x00000522 00           */ IL_0016: nop 480             .try 481             { 482                 /* 0x00000523 06           */ IL_0017: ldloc.0 483                 /* 0x00000524 1FFB         */ IL_0018: ldc.i4.s  -5 484                 /* 0x00000526 59           */ IL_001A: sub 485                 /* 0x00000527 17           */ IL_001B: ldc.i4.1 486                 /* 0x00000528 3608         */ IL_001C: ble.un.s  IL_0026 487  488                 /* 0x0000052A 2B00         */ IL_001E: br.s      IL_0020 489  490                 /* 0x0000052C 06           */ IL_0020: ldloc.0 491                 /* 0x0000052D 17           */ IL_0021: ldc.i4.1 492                 /* 0x0000052E 2E02         */ IL_0022: beq.s     IL_0026 493  494                 /* 0x00000530 2B25         */ IL_0024: br.s      IL_004B 495  496                 /* 0x00000532 00           */ IL_0026: nop 497                 .try 498                 { 499                     /* 0x00000533 06           */ IL_0027: ldloc.0 500                     /* 0x00000534 1FFB         */ IL_0028: ldc.i4.s  -5 501                     /* 0x00000536 2E08         */ IL_002A: beq.s     IL_0034 502  503                     /* 0x00000538 2B00         */ IL_002C: br.s      IL_002E 504  505                     /* 0x0000053A 06           */ IL_002E: ldloc.0 506                     /* 0x0000053B 17           */ IL_002F: ldc.i4.1 507                     /* 0x0000053C 2E02         */ IL_0030: beq.s     IL_0034 508  509                     /* 0x0000053E 2B0C         */ IL_0032: br.s      IL_0040 510  511                     /* 0x00000540 00           */ IL_0034: nop 512                     .try 513                     { 514                         /* 0x00000541 DE07         */ IL_0035: leave.s   IL_003E 515                     } // end .try 516                     finally 517                     { 518                         /* 0x00000543 02           */ IL_0037: ldarg.0 519                         /* 0x00000544 2812000006   */ IL_0038: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally3'() 520                         /* 0x00000549 DC           */ IL_003D: endfinally 521                     } // end handler 522  523                     /* 0x0000054A 2B00         */ IL_003E: br.s      IL_0040 524  525                     /* 0x0000054C DE07         */ IL_0040: leave.s   IL_0049 526                 } // end .try 527                 finally 528                 { 529                     /* 0x0000054E 02           */ IL_0042: ldarg.0 530                     /* 0x0000054F 2811000006   */ IL_0043: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally2'() 531                     /* 0x00000554 DC           */ IL_0048: endfinally 532                 } // end handler 533  534                 /* 0x00000555 2B00         */ IL_0049: br.s      IL_004B 535  536                 /* 0x00000557 DE07         */ IL_004B: leave.s   IL_0054 537             } // end .try 538             finally 539             { 540                 /* 0x00000559 02           */ IL_004D: ldarg.0 541                 /* 0x0000055A 2810000006   */ IL_004E: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally1'() 542                 /* 0x0000055F DC           */ IL_0053: endfinally 543             } // end handler 544  545             /* 0x00000560 2B00         */ IL_0054: br.s      IL_0056 546  547             /* 0x00000562 2A           */ IL_0056: ret 548         } // end of method '<CreateCollection>d__1'::System.IDisposable.Dispose 549  550         // Token: 0x0600000F RID: 15 RVA: 0x0000238C File Offset: 0x0000058C 551         .method private final hidebysig newslot virtual  552             instance bool MoveNext () cil managed  553         { 554             .override method instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() 555             // Header Size: 12 bytes 556             // Code Size: 394 (0x18A) bytes 557             // LocalVarSig Token: 0x11000004 RID: 4 558             .maxstack 3 559             .locals init ( 560                 [0] bool, 561                 [1] int32 562             ) 563  564             .try 565             { 566                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 567                 /* 0x00000598 02           */ IL_0000: ldarg.0 568                 /* 0x00000599 7B08000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 569                 /* 0x0000059E 0B           */ IL_0006: stloc.1 570                 /* 0x0000059F 07           */ IL_0007: ldloc.1 571                 /* 0x000005A0 2C08         */ IL_0008: brfalse.s IL_0012 572  573                 /* 0x000005A2 2B00         */ IL_000A: br.s      IL_000C 574  575                 /* 0x000005A4 07           */ IL_000C: ldloc.1 576                 /* 0x000005A5 17           */ IL_000D: ldc.i4.1 577                 /* 0x000005A6 2E04         */ IL_000E: beq.s     IL_0014 578  579                 /* 0x000005A8 2B07         */ IL_0010: br.s      IL_0019 580  581                 /* 0x000005AA 2B0C         */ IL_0012: br.s      IL_0020 582  583                 /* 0x000005AC 3813010000   */ IL_0014: br        IL_012C 584  585                 /* 0x000005B1 16           */ IL_0019: ldc.i4.0 586                 /* 0x000005B2 0A           */ IL_001A: stloc.0 587                 /* 0x000005B3 DD68010000   */ IL_001B: leave     IL_0188 588  589                 /* 0x000005B8 02           */ IL_0020: ldarg.0 590                 /* 0x000005B9 15           */ IL_0021: ldc.i4.m1 591                 /* 0x000005BA 7D08000004   */ IL_0022: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 592                 /* (39,9)-(39,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 593                 /* 0x000005BF 00           */ IL_0027: nop 594                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 595                 /* 0x000005C0 02           */ IL_0028: ldarg.0 596                 /* 0x000005C1 7309000006   */ IL_0029: newobj    instance void ConsoleApp1.Program/'<>c__DisplayClass1_0'::.ctor() 597                 /* 0x000005C6 7D0B000004   */ IL_002E: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 598                 /* (40,20)-(40,92) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 599                 /* 0x000005CB 02           */ IL_0033: ldarg.0 600                 /* 0x000005CC 7B0B000004   */ IL_0034: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 601                 /* 0x000005D1 732600000A   */ IL_0039: newobj    instance void class [System]System.Collections.Concurrent.BlockingCollection`1<string>::.ctor() 602                 /* 0x000005D6 7D05000004   */ IL_003E: stfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 603                 /* 0x000005DB 02           */ IL_0043: ldarg.0 604                 /* 0x000005DC 1FFD         */ IL_0044: ldc.i4.s  -3 605                 /* 0x000005DE 7D08000004   */ IL_0046: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 606                 /* (41,13)-(41,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 607                 /* 0x000005E3 00           */ IL_004B: nop 608                 /* (42,17)-(42,34) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 609                 /* 0x000005E4 02           */ IL_004C: ldarg.0 610                 /* 0x000005E5 7E01000004   */ IL_004D: ldsfld    object ConsoleApp1.Program::globalLock 611                 /* 0x000005EA 7D0C000004   */ IL_0052: stfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2' 612                 /* 0x000005EF 02           */ IL_0057: ldarg.0 613                 /* 0x000005F0 16           */ IL_0058: ldc.i4.0 614                 /* 0x000005F1 7D0D000004   */ IL_0059: stfld     bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3' 615                 /* 0x000005F6 02           */ IL_005E: ldarg.0 616                 /* 0x000005F7 1FFC         */ IL_005F: ldc.i4.s  -4 617                 /* 0x000005F9 7D08000004   */ IL_0061: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 618                 /* 0x000005FE 02           */ IL_0066: ldarg.0 619                 /* 0x000005FF 7B0C000004   */ IL_0067: ldfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2' 620                 /* 0x00000604 02           */ IL_006C: ldarg.0 621                 /* 0x00000605 7C0D000004   */ IL_006D: ldflda    bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3' 622                 /* 0x0000060A 282700000A   */ IL_0072: call      void [mscorlib]System.Threading.Monitor::Enter(object, bool&) 623                 /* 0x0000060F 00           */ IL_0077: nop 624                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 625                 /* 0x00000610 02           */ IL_0078: ldarg.0 626                 /* 0x00000611 730B000006   */ IL_0079: newobj    instance void ConsoleApp1.Program/'<>c__DisplayClass1_1'::.ctor() 627                 /* 0x00000616 7D0E000004   */ IL_007E: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 628                 /* 0x0000061B 02           */ IL_0083: ldarg.0 629                 /* 0x0000061C 7B0E000004   */ IL_0084: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 630                 /* 0x00000621 02           */ IL_0089: ldarg.0 631                 /* 0x00000622 7B0B000004   */ IL_008A: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 632                 /* 0x00000627 7D07000004   */ IL_008F: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1' 633                 /* (43,17)-(43,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 634                 /* 0x0000062C 00           */ IL_0094: nop 635                 /* (44,21)-(44,42) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 636                 /* 0x0000062D 02           */ IL_0095: ldarg.0 637                 /* 0x0000062E 7B0E000004   */ IL_0096: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 638                 /* 0x00000633 14           */ IL_009B: ldnull 639                 /* 0x00000634 7D06000004   */ IL_009C: stfld     class [mscorlib]System.Exception ConsoleApp1.Program/'<>c__DisplayClass1_1'::err 640                 /* (45,21)-(60,24) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 641                 /* 0x00000639 281800000A   */ IL_00A1: call      class [mscorlib]System.Threading.Tasks.TaskFactory [mscorlib]System.Threading.Tasks.Task::get_Factory() 642                 /* 0x0000063E 02           */ IL_00A6: ldarg.0 643                 /* 0x0000063F 7B0E000004   */ IL_00A7: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 644                 /* 0x00000644 7B07000004   */ IL_00AC: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1' 645                 /* 0x00000649 FE060A000006 */ IL_00B1: ldftn     instance void ConsoleApp1.Program/'<>c__DisplayClass1_0'::'<CreateCollection>b__0'() 646                 /* 0x0000064F 731900000A   */ IL_00B7: newobj    instance void [mscorlib]System.Action::.ctor(object, native int) 647                 /* 0x00000654 6F1A00000A   */ IL_00BC: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.TaskFactory::StartNew(class [mscorlib]System.Action) 648                 /* 0x00000659 02           */ IL_00C1: ldarg.0 649                 /* 0x0000065A 7B0E000004   */ IL_00C2: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 650                 /* 0x0000065F FE060C000006 */ IL_00C7: ldftn     instance void ConsoleApp1.Program/'<>c__DisplayClass1_1'::'<CreateCollection>b__1'(class [mscorlib]System.Threading.Tasks.Task) 651                 /* 0x00000665 732800000A   */ IL_00CD: newobj    instance void class [mscorlib]System.Action`1<class [mscorlib]System.Threading.Tasks.Task>::.ctor(object, native int) 652                 /* 0x0000066A 6F2900000A   */ IL_00D2: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.Task::ContinueWith(class [mscorlib]System.Action`1<class [mscorlib]System.Threading.Tasks.Task>) 653                 /* 0x0000066F 26           */ IL_00D7: pop 654                 /* (62,21)-(62,28) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 655                 /* 0x00000670 00           */ IL_00D8: nop 656                 /* (62,45)-(62,80) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 657                 /* 0x00000671 02           */ IL_00D9: ldarg.0 658                 /* 0x00000672 02           */ IL_00DA: ldarg.0 659                 /* 0x00000673 7B0E000004   */ IL_00DB: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 660                 /* 0x00000678 7B07000004   */ IL_00E0: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<>c__DisplayClass1_1'::'CS$<>8__locals1' 661                 /* 0x0000067D 7B05000004   */ IL_00E5: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 662                 /* 0x00000682 6F2A00000A   */ IL_00EA: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerable`1<!0> class [System]System.Collections.Concurrent.BlockingCollection`1<string>::GetConsumingEnumerable() 663                 /* 0x00000687 6F1500000A   */ IL_00EF: callvirt  instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator() 664                 /* 0x0000068C 7D0F000004   */ IL_00F4: stfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 665                 /* 0x00000691 02           */ IL_00F9: ldarg.0 666                 /* 0x00000692 1FFB         */ IL_00FA: ldc.i4.s  -5 667                 /* 0x00000694 7D08000004   */ IL_00FC: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 668                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 669                 /* 0x00000699 2B39         */ IL_0101: br.s      IL_013C 670  671                 /* (62,30)-(62,41) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 672                 /* 0x0000069B 02           */ IL_0103: ldarg.0 673                 /* 0x0000069C 02           */ IL_0104: ldarg.0 674                 /* 0x0000069D 7B0F000004   */ IL_0105: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 675                 /* 0x000006A2 6F1200000A   */ IL_010A: callvirt  instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current() 676                 /* 0x000006A7 7D10000004   */ IL_010F: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6' 677                 /* (63,21)-(63,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 678                 /* 0x000006AC 00           */ IL_0114: nop 679                 /* (64,25)-(64,43) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 680                 /* 0x000006AD 02           */ IL_0115: ldarg.0 681                 /* 0x000006AE 02           */ IL_0116: ldarg.0 682                 /* 0x000006AF 7B10000004   */ IL_0117: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6' 683                 /* 0x000006B4 7D09000004   */ IL_011C: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current' 684                 /* 0x000006B9 02           */ IL_0121: ldarg.0 685                 /* 0x000006BA 17           */ IL_0122: ldc.i4.1 686                 /* 0x000006BB 7D08000004   */ IL_0123: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 687                 /* 0x000006C0 17           */ IL_0128: ldc.i4.1 688                 /* 0x000006C1 0A           */ IL_0129: stloc.0 689                 /* 0x000006C2 DE5C         */ IL_012A: leave.s   IL_0188 690  691                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 692                 /* 0x000006C4 02           */ IL_012C: ldarg.0 693                 /* 0x000006C5 1FFB         */ IL_012D: ldc.i4.s  -5 694                 /* 0x000006C7 7D08000004   */ IL_012F: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 695                 /* (65,21)-(65,22) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 696                 /* 0x000006CC 00           */ IL_0134: nop 697                 /* 0x000006CD 02           */ IL_0135: ldarg.0 698                 /* 0x000006CE 14           */ IL_0136: ldnull 699                 /* 0x000006CF 7D10000004   */ IL_0137: stfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<item>5__6' 700  701                 /* (62,42)-(62,44) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 702                 /* 0x000006D4 02           */ IL_013C: ldarg.0 703                 /* 0x000006D5 7B0F000004   */ IL_013D: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 704                 /* 0x000006DA 6F1100000A   */ IL_0142: callvirt  instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() 705                 /* 0x000006DF 2DBA         */ IL_0147: brtrue.s  IL_0103 706  707                 /* 0x000006E1 02           */ IL_0149: ldarg.0 708                 /* 0x000006E2 2812000006   */ IL_014A: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally3'() 709                 /* 0x000006E7 00           */ IL_014F: nop 710                 /* 0x000006E8 02           */ IL_0150: ldarg.0 711                 /* 0x000006E9 14           */ IL_0151: ldnull 712                 /* 0x000006EA 7D0F000004   */ IL_0152: stfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 713                 /* (66,17)-(66,18) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 714                 /* 0x000006EF 00           */ IL_0157: nop 715                 /* 0x000006F0 02           */ IL_0158: ldarg.0 716                 /* 0x000006F1 14           */ IL_0159: ldnull 717                 /* 0x000006F2 7D0E000004   */ IL_015A: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_1' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__4' 718                 /* 0x000006F7 02           */ IL_015F: ldarg.0 719                 /* 0x000006F8 2811000006   */ IL_0160: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally2'() 720                 /* 0x000006FD 00           */ IL_0165: nop 721                 /* 0x000006FE 02           */ IL_0166: ldarg.0 722                 /* 0x000006FF 14           */ IL_0167: ldnull 723                 /* 0x00000700 7D0C000004   */ IL_0168: stfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2' 724                 /* (67,13)-(67,14) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 725                 /* 0x00000705 00           */ IL_016D: nop 726                 /* 0x00000706 02           */ IL_016E: ldarg.0 727                 /* 0x00000707 2810000006   */ IL_016F: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::'<>m__Finally1'() 728                 /* 0x0000070C 00           */ IL_0174: nop 729                 /* 0x0000070D 02           */ IL_0175: ldarg.0 730                 /* 0x0000070E 14           */ IL_0176: ldnull 731                 /* 0x0000070F 7D0B000004   */ IL_0177: stfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 732                 /* (68,9)-(68,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 733                 /* 0x00000714 16           */ IL_017C: ldc.i4.0 734                 /* 0x00000715 0A           */ IL_017D: stloc.0 735                 /* 0x00000716 DE08         */ IL_017E: leave.s   IL_0188 736             } // end .try 737             fault 738             { 739                 /* (hidden)-(hidden) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 740                 /* 0x00000718 02           */ IL_0180: ldarg.0 741                 /* 0x00000719 280E000006   */ IL_0181: call      instance void ConsoleApp1.Program/'<CreateCollection>d__1'::System.IDisposable.Dispose() 742                 /* 0x0000071E 00           */ IL_0186: nop 743                 /* 0x0000071F DC           */ IL_0187: endfinally 744             } // end handler 745  746             /* 0x00000720 06           */ IL_0188: ldloc.0 747             /* 0x00000721 2A           */ IL_0189: ret 748         } // end of method '<CreateCollection>d__1'::MoveNext 749  750         // Token: 0x06000010 RID: 16 RVA: 0x00002540 File Offset: 0x00000740 751         .method private hidebysig  752             instance void '<>m__Finally1' () cil managed  753         { 754             // Header Size: 1 byte 755             // Code Size: 38 (0x26) bytes 756             .maxstack 8 757  758             /* 0x00000741 02           */ IL_0000: ldarg.0 759             /* 0x00000742 15           */ IL_0001: ldc.i4.m1 760             /* 0x00000743 7D08000004   */ IL_0002: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 761             /* 0x00000748 02           */ IL_0007: ldarg.0 762             /* 0x00000749 7B0B000004   */ IL_0008: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 763             /* 0x0000074E 7B05000004   */ IL_000D: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 764             /* 0x00000753 2C11         */ IL_0012: brfalse.s IL_0025 765  766             /* 0x00000755 02           */ IL_0014: ldarg.0 767             /* 0x00000756 7B0B000004   */ IL_0015: ldfld     class ConsoleApp1.Program/'<>c__DisplayClass1_0' ConsoleApp1.Program/'<CreateCollection>d__1'::'<>8__1' 768             /* 0x0000075B 7B05000004   */ IL_001A: ldfld     class [System]System.Collections.Concurrent.BlockingCollection`1<string> ConsoleApp1.Program/'<>c__DisplayClass1_0'::collection 769             /* 0x00000760 6F1000000A   */ IL_001F: callvirt  instance void [mscorlib]System.IDisposable::Dispose() 770             /* 0x00000765 00           */ IL_0024: nop 771  772             /* 0x00000766 2A           */ IL_0025: ret 773         } // end of method '<CreateCollection>d__1'::'<>m__Finally1' 774  775         // Token: 0x06000011 RID: 17 RVA: 0x00002567 File Offset: 0x00000767 776         .method private hidebysig  777             instance void '<>m__Finally2' () cil managed  778         { 779             // Header Size: 1 byte 780             // Code Size: 29 (0x1D) bytes 781             .maxstack 8 782  783             /* 0x00000768 02           */ IL_0000: ldarg.0 784             /* 0x00000769 1FFD         */ IL_0001: ldc.i4.s  -3 785             /* 0x0000076B 7D08000004   */ IL_0003: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 786             /* 0x00000770 02           */ IL_0008: ldarg.0 787             /* 0x00000771 7B0D000004   */ IL_0009: ldfld     bool ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__3' 788             /* 0x00000776 2C0C         */ IL_000E: brfalse.s IL_001C 789  790             /* 0x00000778 02           */ IL_0010: ldarg.0 791             /* 0x00000779 7B0C000004   */ IL_0011: ldfld     object ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__2' 792             /* 0x0000077E 282B00000A   */ IL_0016: call      void [mscorlib]System.Threading.Monitor::Exit(object) 793             /* 0x00000783 00           */ IL_001B: nop 794  795             /* 0x00000784 2A           */ IL_001C: ret 796         } // end of method '<CreateCollection>d__1'::'<>m__Finally2' 797  798         // Token: 0x06000012 RID: 18 RVA: 0x00002585 File Offset: 0x00000785 799         .method private hidebysig  800             instance void '<>m__Finally3' () cil managed  801         { 802             // Header Size: 1 byte 803             // Code Size: 29 (0x1D) bytes 804             .maxstack 8 805  806             /* 0x00000786 02           */ IL_0000: ldarg.0 807             /* 0x00000787 1FFC         */ IL_0001: ldc.i4.s  -4 808             /* 0x00000789 7D08000004   */ IL_0003: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 809             /* 0x0000078E 02           */ IL_0008: ldarg.0 810             /* 0x0000078F 7B0F000004   */ IL_0009: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 811             /* 0x00000794 2C0C         */ IL_000E: brfalse.s IL_001C 812  813             /* 0x00000796 02           */ IL_0010: ldarg.0 814             /* 0x00000797 7B0F000004   */ IL_0011: ldfld     class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'<>s__5' 815             /* 0x0000079C 6F1000000A   */ IL_0016: callvirt  instance void [mscorlib]System.IDisposable::Dispose() 816             /* 0x000007A1 00           */ IL_001B: nop 817  818             /* 0x000007A2 2A           */ IL_001C: ret 819         } // end of method '<CreateCollection>d__1'::'<>m__Finally3' 820  821         // Token: 0x06000013 RID: 19 RVA: 0x000025A3 File Offset: 0x000007A3 822         .method private final hidebysig specialname newslot virtual  823             instance string 'System.Collections.Generic.IEnumerator<System.String>.get_Current' () cil managed  824         { 825             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 826                 01 00 00 00 827             ) 828             .override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current() 829             // Header Size: 1 byte 830             // Code Size: 7 (0x7) bytes 831             .maxstack 8 832  833             /* 0x000007A4 02           */ IL_0000: ldarg.0 834             /* 0x000007A5 7B09000004   */ IL_0001: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current' 835             /* 0x000007AA 2A           */ IL_0006: ret 836         } // end of method '<CreateCollection>d__1'::'System.Collections.Generic.IEnumerator<System.String>.get_Current' 837  838         // Token: 0x06000014 RID: 20 RVA: 0x000025AB File Offset: 0x000007AB 839         .method private final hidebysig newslot virtual  840             instance void System.Collections.IEnumerator.Reset () cil managed  841         { 842             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 843                 01 00 00 00 844             ) 845             .override method instance void [mscorlib]System.Collections.IEnumerator::Reset() 846             // Header Size: 1 byte 847             // Code Size: 6 (0x6) bytes 848             .maxstack 8 849  850             /* 0x000007AC 732C00000A   */ IL_0000: newobj    instance void [mscorlib]System.NotSupportedException::.ctor() 851             /* 0x000007B1 7A           */ IL_0005: throw 852         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerator.Reset 853  854         // Token: 0x06000015 RID: 21 RVA: 0x000025B2 File Offset: 0x000007B2 855         .method private final hidebysig specialname newslot virtual  856             instance object System.Collections.IEnumerator.get_Current () cil managed  857         { 858             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 859                 01 00 00 00 860             ) 861             .override method instance object [mscorlib]System.Collections.IEnumerator::get_Current() 862             // Header Size: 1 byte 863             // Code Size: 7 (0x7) bytes 864             .maxstack 8 865  866             /* 0x000007B3 02           */ IL_0000: ldarg.0 867             /* 0x000007B4 7B09000004   */ IL_0001: ldfld     string ConsoleApp1.Program/'<CreateCollection>d__1'::'<>2__current' 868             /* 0x000007B9 2A           */ IL_0006: ret 869         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerator.get_Current 870  871         // Token: 0x06000016 RID: 22 RVA: 0x000025BC File Offset: 0x000007BC 872         .method private final hidebysig newslot virtual  873             instance class [mscorlib]System.Collections.Generic.IEnumerator`1<string> 'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator' () cil managed  874         { 875             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 876                 01 00 00 00 877             ) 878             .override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<string>::GetEnumerator() 879             // Header Size: 12 bytes 880             // Code Size: 48 (0x30) bytes 881             // LocalVarSig Token: 0x11000005 RID: 5 882             .maxstack 2 883             .locals init ( 884                 [0] class ConsoleApp1.Program/'<CreateCollection>d__1' 885             ) 886  887             /* 0x000007C8 02           */ IL_0000: ldarg.0 888             /* 0x000007C9 7B08000004   */ IL_0001: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 889             /* 0x000007CE 1FFE         */ IL_0006: ldc.i4.s  -2 890             /* 0x000007D0 331D         */ IL_0008: bne.un.s  IL_0027 891  892             /* 0x000007D2 02           */ IL_000A: ldarg.0 893             /* 0x000007D3 7B0A000004   */ IL_000B: ldfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>l__initialThreadId' 894             /* 0x000007D8 281D00000A   */ IL_0010: call      class [mscorlib]System.Threading.Thread [mscorlib]System.Threading.Thread::get_CurrentThread() 895             /* 0x000007DD 6F1E00000A   */ IL_0015: callvirt  instance int32 [mscorlib]System.Threading.Thread::get_ManagedThreadId() 896             /* 0x000007E2 330B         */ IL_001A: bne.un.s  IL_0027 897  898             /* 0x000007E4 02           */ IL_001C: ldarg.0 899             /* 0x000007E5 16           */ IL_001D: ldc.i4.0 900             /* 0x000007E6 7D08000004   */ IL_001E: stfld     int32 ConsoleApp1.Program/'<CreateCollection>d__1'::'<>1__state' 901             /* 0x000007EB 02           */ IL_0023: ldarg.0 902             /* 0x000007EC 0A           */ IL_0024: stloc.0 903             /* 0x000007ED 2B07         */ IL_0025: br.s      IL_002E 904  905             /* 0x000007EF 16           */ IL_0027: ldc.i4.0 906             /* 0x000007F0 730D000006   */ IL_0028: newobj    instance void ConsoleApp1.Program/'<CreateCollection>d__1'::.ctor(int32) 907             /* 0x000007F5 0A           */ IL_002D: stloc.0 908  909             /* 0x000007F6 06           */ IL_002E: ldloc.0 910             /* 0x000007F7 2A           */ IL_002F: ret 911         } // end of method '<CreateCollection>d__1'::'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator' 912  913         // Token: 0x06000017 RID: 23 RVA: 0x000025F8 File Offset: 0x000007F8 914         .method private final hidebysig newslot virtual  915             instance class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () cil managed  916         { 917             .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 918                 01 00 00 00 919             ) 920             .override method instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator() 921             // Header Size: 1 byte 922             // Code Size: 7 (0x7) bytes 923             .maxstack 8 924  925             /* 0x000007F9 02           */ IL_0000: ldarg.0 926             /* 0x000007FA 2816000006   */ IL_0001: call      instance class [mscorlib]System.Collections.Generic.IEnumerator`1<string> ConsoleApp1.Program/'<CreateCollection>d__1'::'System.Collections.Generic.IEnumerable<System.String>.GetEnumerator'() 927             /* 0x000007FF 2A           */ IL_0006: ret 928         } // end of method '<CreateCollection>d__1'::System.Collections.IEnumerable.GetEnumerator 929  930         // Properties 931         // Token: 0x17000001 RID: 1 932         .property instance string 'System.Collections.Generic.IEnumerator<System.String>.Current'() 933         { 934             // Token: 0x06000013 RID: 19 RVA: 0x000025A3 File Offset: 0x000007A3 935             .get instance string ConsoleApp1.Program/'<CreateCollection>d__1'::'System.Collections.Generic.IEnumerator<System.String>.get_Current'() 936         } 937         // Token: 0x17000002 RID: 2 938         .property instance object System.Collections.IEnumerator.Current() 939         { 940             // Token: 0x06000015 RID: 21 RVA: 0x000025B2 File Offset: 0x000007B2 941             .get instance object ConsoleApp1.Program/'<CreateCollection>d__1'::System.Collections.IEnumerator.get_Current() 942         } 943  944     } // end of class <CreateCollection>d__1 945  946  947     // Fields 948     // Token: 0x04000001 RID: 1 949     .field private static initonly object globalLock 950  951     // Methods 952     // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250 953     .method public hidebysig static 
 954         void Main ( 955             string[] args 956         ) cil managed  957     { 958         // Header Size: 12 bytes 959         // Code Size: 92 (0x5C) bytes 960         .maxstack 3 961         .entrypoint 962  963         /* (12,9)-(12,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 964         /* 0x0000025C 00           */ IL_0000: nop 965         /* (13,13)-(22,16) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 966         /* 0x0000025D 281800000A   */ IL_0001: call      class [mscorlib]System.Threading.Tasks.TaskFactory [mscorlib]System.Threading.Tasks.Task::get_Factory() 967         /* 0x00000262 7E03000004   */ IL_0006: ldsfld    class [mscorlib]System.Action ConsoleApp1.Program/'<>c'::'<>9__0_0' 968         /* 0x00000267 25           */ IL_000B: dup 969         /* 0x00000268 2D17         */ IL_000C: brtrue.s  IL_0025 970  971         /* 0x0000026A 26           */ IL_000E: pop 972         /* 0x0000026B 7E02000004   */ IL_000F: ldsfld    class ConsoleApp1.Program/'<>c' ConsoleApp1.Program/'<>c'::'<>9' 973         /* 0x00000270 FE0607000006 */ IL_0014: ldftn     instance void ConsoleApp1.Program/'<>c'::'<Main>b__0_0'() 974         /* 0x00000276 731900000A   */ IL_001A: newobj    instance void [mscorlib]System.Action::.ctor(object, native int) 975         /* 0x0000027B 25           */ IL_001F: dup 976         /* 0x0000027C 8003000004   */ IL_0020: stsfld    class [mscorlib]System.Action ConsoleApp1.Program/'<>c'::'<>9__0_0' 977  978         /* 0x00000281 6F1A00000A   */ IL_0025: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.TaskFactory::StartNew(class [mscorlib]System.Action) 979         /* 0x00000286 26           */ IL_002A: pop 980         /* (24,13)-(33,16) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 981         /* 0x00000287 281800000A   */ IL_002B: call      class [mscorlib]System.Threading.Tasks.TaskFactory [mscorlib]System.Threading.Tasks.Task::get_Factory() 982         /* 0x0000028C 7E04000004   */ IL_0030: ldsfld    class [mscorlib]System.Action ConsoleApp1.Program/'<>c'::'<>9__0_1' 983         /* 0x00000291 25           */ IL_0035: dup 984         /* 0x00000292 2D17         */ IL_0036: brtrue.s  IL_004F 985  986         /* 0x00000294 26           */ IL_0038: pop 987         /* 0x00000295 7E02000004   */ IL_0039: ldsfld    class ConsoleApp1.Program/'<>c' ConsoleApp1.Program/'<>c'::'<>9' 988         /* 0x0000029A FE0608000006 */ IL_003E: ldftn     instance void ConsoleApp1.Program/'<>c'::'<Main>b__0_1'() 989         /* 0x000002A0 731900000A   */ IL_0044: newobj    instance void [mscorlib]System.Action::.ctor(object, native int) 990         /* 0x000002A5 25           */ IL_0049: dup 991         /* 0x000002A6 8004000004   */ IL_004A: stsfld    class [mscorlib]System.Action ConsoleApp1.Program/'<>c'::'<>9__0_1' 992  993         /* 0x000002AB 6F1A00000A   */ IL_004F: callvirt  instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Threading.Tasks.TaskFactory::StartNew(class [mscorlib]System.Action) 994         /* 0x000002B0 26           */ IL_0054: pop 995         /* (35,13)-(35,31) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 996         /* 0x000002B1 281B00000A   */ IL_0055: call      valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey() 997         /* 0x000002B6 26           */ IL_005A: pop 998         /* (36,9)-(36,10) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */ 999         /* 0x000002B7 2A           */ IL_005B: ret1000     } // end of method Program::Main1001 1002     // Token: 0x06000002 RID: 2 RVA: 0x000020B8 File Offset: 0x000002B81003     .method private hidebysig static 
1004         class [mscorlib]System.Collections.Generic.IEnumerable`1<string> CreateCollection () cil managed 1005     {1006         // Header Size: 1 byte1007         // Code Size: 8 (0x8) bytes1008         .maxstack 81009 1010         /* 0x000002B9 1FFE         */ IL_0000: ldc.i4.s  -21011         /* 0x000002BB 730D000006   */ IL_0002: newobj    instance void ConsoleApp1.Program/'<CreateCollection>d__1'::.ctor(int32)1012         /* 0x000002C0 2A           */ IL_0007: ret1013     } // end of method Program::CreateCollection1014 1015     // Token: 0x06000003 RID: 3 RVA: 0x000020C1 File Offset: 0x000002C11016     .method public hidebysig specialname rtspecialname 1017         instance void .ctor () cil managed 1018     {1019         // Header Size: 1 byte1020         // Code Size: 8 (0x8) bytes1021         .maxstack 81022 1023         /* 0x000002C2 02           */ IL_0000: ldarg.01024         /* 0x000002C3 281C00000A   */ IL_0001: call      instance void [mscorlib]System.Object::.ctor()1025         /* 0x000002C8 00           */ IL_0006: nop1026         /* 0x000002C9 2A           */ IL_0007: ret1027     } // end of method Program::.ctor1028 1029     // Token: 0x06000004 RID: 4 RVA: 0x000020CA File Offset: 0x000002CA1030     .method private hidebysig specialname rtspecialname static 
1031         void .cctor () cil managed 1032     {1033         // Header Size: 1 byte1034         // Code Size: 11 (0xB) bytes1035         .maxstack 81036 1037         /* (70,9)-(70,66) C:\Users\rismo202\source\repos\ConsoleApp1\ConsoleApp1\Program.cs */1038         /* 0x000002CB 731C00000A   */ IL_0000: newobj    instance void [mscorlib]System.Object::.ctor()1039         /* 0x000002D0 8001000004   */ IL_0005: stsfld    object ConsoleApp1.Program::globalLock1040         /* 0x000002D5 2A           */ IL_000A: ret1041     } // end of method Program::.cctor1042 1043 } // end of class ConsoleApp1.Program

View Code

查看IL,我们发现在掉用 '<CreateCollection>d__1'.MoveNext() 方法时,加了锁,在调用 '<CreateCollection>d__1''<>m__Finally2'() 方法时(调用结束时)解了锁。

但是,如果我们在第一次调用 MoveNext() 之前,另一个线程调用了 CreateCollection() 方法,那么可能第二个线程可能先执行。

总结:

1、对于yield方法来说,在所有操作上加锁,并不能保证 yield 方法体内的代码同步;

2、yield方法体内的代码,只有在调用 MoveNext() 方法时才会调用;

 

标签:__,ConsoleApp1,return,C#,System,yield,mscorlib,Program,IL
来源: https://blog.51cto.com/u_11551997/2711767