Exemplo n.º 1
0
 static void Main(string[] args)
 {
     IWorker worker = new GoodWorker();
     worker.DoWork();
     IWorker lazyworker = new LazyWorker();
     lazyworker.DoWork();
     Console.ReadKey();
 }
Exemplo n.º 2
0
 public void DoWork()
 {
     Console.WriteLine($"\nLazy work got a new task.");
     if (this._worker == null)
     {
         this._worker = new GoodWorker();
     }
     this._worker.DoWork();
 }