static void Main(string[] args) { var list = Message1.CreateMessages(10000); // Do whatever you want with the list. }