I looked for a way to display the progress dialog myself and finally came across a class called CommonMessagePump that provides the same wait dialog that appears in Visual Studio when operations take a lot of time.
A little cumbersome to use, but it seems to work very well. It does not appear until your operation took two seconds or so, and it also supports cancellation.
Assuming you have a class named Item and that it contains the Name property, and you want to process a list of these elements, this can be done as follows:
void MyLengthyOperation(IList<Item> items) { CommonMessagePump msgPump = new CommonMessagePump(); msgPump.AllowCancel = true; msgPump.EnableRealProgress = true; msgPump.WaitTitle = "Doing stuff..." msgPump.WaitText = "Please wait while doing stuff."; CancellationTokenSource cts = new CancellationTokenSource(); Task task = Task.Run(() => { for (int i = 0; i < items.Count; i++) { cts.Token.ThrowIfCancellationRequested(); msgPump.CurrentStep = i + 1; msgPump.ProgressText = String.Format("Processing Item {0}/{1}: {2}", i + 1, msgPump.TotalSteps, items[i].Name);
Decaf source share