【发布时间】:2017-04-27 01:12:23
【问题描述】:
我在我的 uwp 项目中使用后台工作者。在这里,我想在后台工作人员运行时显示加载图像。后台工作任务完成后,加载图像应该是不可见的。 我该怎么做。
BackgroundWorker productPrices = new BackgroundWorker();
productPrices.DoWork += new DoWorkEventHandler(productPrices_Dowork);
productPrices.RunWorkerCompleted += productPrices_RunWorkerCompleted;
productPrices.WorkerSupportsCancellation = true;
productPrices.ProgressChanged += new ProgressChangedEventHandler(productPrices_ProgressChanged);
productPrices.WorkerReportsProgress = true;
private async void productPrices_Dowork(object sender, DoWorkEventArgs e)
{
progressring.Visibility = Visibility.Visible;
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
string customerId = Application.Current.Resources[Constants.CUSTOMER_ID].ToString();
string username = Application.Current.Resources[Constants.EMAIL_ID].ToString();
string strIpAddress = Application.Current.Resources[Constants.IP_ADDRESS].ToString();
string strPortNumber = Application.Current.Resources[Constants.PORT_Number].ToString();
RequestHeader requestHeader = DBHelper.GetRequestHeader(customerId, customerId, username);
string strStoreLocation = Application.Current.Resources[Constants.STORE_LOCATION].ToString();
int startIndex = 0;
await ProductAgent.GetProductPrices(requestHeader, strIpAddress, strPortNumber, strStoreLocation);
});
}
【问题讨论】:
-
我们绝对可以做到,你有没有尝试过什么?
-
我已经编辑了我的问题
-
实际上在 UWP 平台中内置了一些您可以使用的东西。它的名字叫
ProgressRing这会满足您的需求还是需要自定义图像?如果是后者,请查看this page 获取一些提示 -
进度环足够了,但我无法在后台工作人员运行时显示它
标签: c# .net windows uwp win-universal-app