小编Ang*_*ela的帖子

Backgroundworker不会报告进度

我有一个运行长数据库任务的后台工作程序.我想在任务运行时显示进度条.不知何故,后台工作人员不会报告任务的进度.

这就是我所拥有的:

BackgroundWorker _bgwLoadClients;

_bgwLoadClients = new BackgroundWorker();
_bgwLoadClients.WorkerReportsProgress = true;
_bgwLoadClients.DoWork += new DoWorkEventHandler(_bgwLoadClients_DoWork);
_bgwLoadClients.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_bgwLoadClients_RunWorkerCompleted);
_bgwLoadClients.ProgressChanged += new ProgressChangedEventHandler(_bgwLoadClients_ProgressChanged);
_bgwLoadClients.RunWorkerAsync(parms);

private void _bgwLoadClients_DoWork(object sender, DoWorkEventArgs e)
{
    DataTable dt = getdate();
    e.Result = dt;
}

void _bgwLoadClients_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    progressBar1.Value = e.ProgressPercentage;
}
Run Code Online (Sandbox Code Playgroud)

我在WPF中这样做,但我想它不会有所作为.

提前致谢

c# wpf progress backgroundworker

18
推荐指数
2
解决办法
3万
查看次数

ComboBox绑定到枚举,我做错了什么?

我已经四处搜索,将枚举绑定到组合框似乎很容易,只需通过静态Enum.GetValues方法通过ObjectDataProvider将Enum值作为字符串列表检索,但是我无法使其工作.错误是未找到类型ContactExportType.

我有一个名为ContactExportType的枚举,它驻留在Enums类中.此类是CEM.Marketing.Objects命名空间的一部分.

这就是我所拥有的:

<UserControl 
 xmlns:local="clr-namespace:CEM.Marketing.Objects"
 xmlns:sys="clr-namespace:System;assembly=mscorlib">

<Grid>
<Grid.Resources>
        <ObjectDataProvider MethodName="GetValues"
                    ObjectType="{x:Type sys:Enum}"
                    x:Key="ContactExportTypes">
        <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="local:ContactExportType" />
        </ObjectDataProvider.MethodParameters>

    </ObjectDataProvider>
    </Grid.Resources>

</Grid>
 <ComboBox 
        ItemsSource="{Binding {StaticResource ContactExportTypes}}"
...
Run Code Online (Sandbox Code Playgroud)

谢谢,安吉拉

wpf enums combobox

14
推荐指数
1
解决办法
2万
查看次数

标签 统计

wpf ×2

backgroundworker ×1

c# ×1

combobox ×1

enums ×1

progress ×1