- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
using System;
class TLockCriticalSystemResource : IDisposable
{
public TLockCriticalSystemResource(){Console.WriteLine("Acquire critical system resource");}
public void Dispose(){Console.WriteLine("Release critical system resource");}
public bool Property1{private get{return true;}set{throw new Exception();}}
}
public class Test
{
public static void Main()
{
using (var file = new TLockCriticalSystemResource()
{
Property1=true
})
{
// Делаем чего-то с ресурсом
}
}
}
Follow us!