Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void AddItems( )
- {
- for (int i = 0; i < 100; i++)
- lock (list)
- list.Add ("Item " + list.Count);
- string[] items;
- lock (list) items = list.ToArray( );
- foreach (string s in items) Console.WriteLine (s);
- }
- lock (list)
- list.Add ("Item " + list.Count);
- lock (list) items = list.ToArray( );
- class UsefulStuff {
- object _TheLock = new object { };
- public void UsefulThingNumberOne() {
- lock(_TheLock) {
- //CodeBlockA
- }
- }
- public void UsefulThingNumberTwo() {
- lock(_TheLock) {
- //CodeBlockB
- }
- }
- }
- public class Foo
- {
- private static Foo instance = new Foo();
- public static Foo Instance
- {
- get { return instance; }
- }
- }
Add Comment
Please, Sign In to add comment