It may not be obvious how to use GetProgressView() to report to the user the progress of something that takes some time.
If you look at the help for ShowDialog method of the IProgressView Interface you will see that one of the arguments is a task form the System.Threading.Tasks:
This post has a good discussion about tasks.
Below is a c# example that shows the progress view and updates a couple of times until the task is done. This screenshot shows the dialog as the task is running.
private void button3_Click(object sender, EventArgs e)
{
// test_IProgressView();
Framework.Forms.Interfaces.IProgressView
myProgressView = null;
System.Threading.CancellationTokenSource
tokenSource =
new System.Threading.CancellationTokenSource();
var token = tokenSource.Token;
System.Threading.Tasks.Task taskWithToken =
new System.Threading.Tasks.Task(
() =>
{
while (true)
{
//Wait - similates doing something
System.Threading.Thread.Sleep(1000 * 5);
// Need this for an argument to
// ReportProgress to use it make a class
// that derives from IEnumerable
System.Collections.Generic.IEnumerable
<Framework.Currency.ProgressValue>
myProgressValues = null;
int intPercentageComplete = 10;
myProgressView.ReportProgress("Doing something",
"10 Percent complete",
myProgressValues, intPercentageComplete);
// See if the user hit cancel
if (tokenSource.IsCancellationRequested)
{
break;
}
//This is going to do something with vault as a
//test Change to something in your application
string localPath = @"C:\temp\wbtest_7_22_14.txt";
string fileName = "wbtest_7_22_14.txt";
ACW.Folder vaultFolder = new ACW.Folder();
string comment = "New Comment";
ACW.File myFile = AddOrUpdateFile
(localPath, fileName, vaultFolder, comment);
if (tokenSource.IsCancellationRequested)
{
break;
}
intPercentageComplete = 30;
myProgressView.ReportProgress("Doing Something",
"30 percent complete",
myProgressValues, intPercentageComplete);
//Wait - similates doing something
System.Threading.Thread.Sleep(1000 * 5);
intPercentageComplete = 80;
myProgressView.ReportProgress("Doing Something",
"80 Percent complete",
myProgressValues, intPercentageComplete);
//Wait - similates doing something
System.Threading.Thread.Sleep(1000 * 5);
// Finish task
break;
}
}, token
);
taskWithToken.Start();
myProgressView = Framework.Forms.Library.
GetProgressView("Doing Something", "Started");
myProgressView.ShowDialog
(taskWithToken, tokenSource);
}