show the process of loading objects, display the percentage and time in the dialog box
private void LoadingBar(int delay, int max, int current, String message, String title) { if (max < current) { max = current; } int percent = (int)Math.Round(((double)current / max) * 100); if (delay >= max) { delay = max - 1; } if (current < delay) { current = delay; } TimeSpan ts = TimeSpan.FromSeconds(((max - current) / delay) * ((max - delay) / 100)); ts = ts.Subtract(TimeSpan.FromSeconds(((max - current) / delay) * ((max - delay) % 100) / 100)); if (percent > 100) { percent = 100; } MessageBox.Show(message, title + percent + "% (" + ts.ToString(@"hh\:mm\:ss") + ")", MessageBoxButtons.OK, MessageBoxIcon.Information); }