I have a C# "foreach" loop I would like to run a batch of 100, then pause for a specified period of time. How can I go about batch processing a "foreach" loop? I have tried many examples and all have failed. Here is the code contaning the loop. Thank you very much.
foreach (string filename in filenames) { PictureBox pic = new PictureBox(); pic.ClientSize = new Size(ThumbWidth, ThumbHeight); pic.Image = new Bitmap(filename); if ((pic.Image.Width > ThumbWidth) || (pic.Image.Height > ThumbHeight)) { pic.SizeMode = PictureBoxSizeMode.Zoom; } else { pic.SizeMode = PictureBoxSizeMode.CenterImage; } pic.DoubleClick += PictureBox_DoubleClick; FileInfo file_info = new FileInfo(filename); tipPicture.SetToolTip(pic, file_info.Name + "\nCreated: " + file_info.CreationTime.ToShortDateString() + "\n(" + pic.Image.Width + " x " + pic.Image.Height + ") " + ToFileSizeApi(file_info.Length)); pic.Tag = file_info; pic.Parent = flpThumbnails; }
https://stackoverflow.com/questions/67342825/batch-pause-foreach-loop-after-specified-number-of-returns May 01, 2021 at 12:15PM
没有评论:
发表评论