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