static void Main(string[] args) { var container = new TaskContainer(); ITaskExample example = null; while ((example = container.GetTaskExample()) != null) { example.Execute(); Console.WriteLine("Example is processed"); } }