0
如何從下面返回進度狀態?我是否正確使用IProgress狀態?我曾假設某處會有一個Progress.report()函數,但似乎並不存在。返回進度狀態
public static void Main()
{
Console.WriteLine("Running Async Methods");
AsynchronousMethods am = new AsynchronousMethods();
Progress<int> p = new Progress<int>();
Task ta = am.asyncMethods(p);
while (!ta.IsCompleted)
{
// report progress
// I would liek to return the Progress here. I am not sure how?
// there doesnt seem to be a P.result
}
ta.Wait();
}
public async Task asyncMethods(IProgress<int> pro)
{
await Task.Run(() =>
{
for (int i = 0; i < 1999; i++)
{
Console.WriteLine("I is {0}", i);
pro.Report(i * 2);
}
});
}
有一個事件'ProgressChanged' – SimpleVar 2014-08-31 09:45:34