2
我想使我的進度工作的Windows手機8.1。進度中的Windows Phone 8.1
這裏是我的代碼:
using (var writeStream = await newZipFile.OpenAsync(FileAccessMode.ReadWrite))
{
using (var outputStream = writeStream.GetOutputStreamAt(0))
{
using (var dataWriter = new DataWriter(outputStream))
{
using (Stream input = webResponse.GetResponseStream())
{
long totalSize = 0;
int read;
uint zeroUint = Convert.ToUInt32(0);
uint readUint;
while ((read = input.Read(buffer, 0, buffer.Length)) >0)
{
// totalSize += read;
totalSize = totalSize + read;
//pb2.Value = totalSize * 100/sizeFit;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
//Declaration of variables
// load.progresschanged(totalSize * 100/sizeFit);
pb2.Value = totalSize * 100/sizeFit;
});
readUint = Convert.ToUInt32(read);
IBuffer ibuffer = buffer.AsBuffer();
dataWriter.WriteBuffer(ibuffer, zeroUint, readUint);
}
await dataWriter.StoreAsync();
await outputStream.FlushAsync();
dataWriter.DetachStream();
}
}
}
}
這裏的問題是,只有進度更新時的值爲100 任何幫助表示讚賞。
使用'DispatcherTimer'來檢查並設置進度條中的值 –