为什么 Silverlight 弹出窗口在进行计算时挂起?

发布于 2025-01-01 04:19:57 字数 219 浏览 3 评论 0原文

我在银光中创建了一个自定义日期时间控件,在我的银光自定义控件中,有属性名称“EditDate”,该日期是在活页夹的帮助下设置的,并且基本上进行两种方式绑定,当我从日期时间设置编辑日期时选择器,它很好地设置了我的外部属性,在设置外部属性时,有一个执行一些计算的 setter 事件,现在的问题是在计算正在进行时我的日期时间选择器弹出窗口保持打开状态,有什么方法可以立即隐藏它设置后“编辑日期”?

谢谢 阿曼。

I have create a custom date time control in silver light , in my silver light custom control there is property names "EditDate" this date is set with the help of binder , and basically doing two way binding , when i set edit date from date time picker , it well set my external property and while setting external property there is a setter event which performs some calculations , now the issue is while the calculation is in progress my date time picker popup remain opened , is there any way i can hide it immediately after setting "EditDate" ?

Thanks
Aman.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

网白 2025-01-08 04:19:57

我认为计算会冻结 UI 线程。将计算放入BackgroundWorker 中,以便在处理计算时更新UI。

var bw = new BackgroundWorker();
//Will fire when backgroundworker starts
bw.DoWork += (snd, arg) =>
    {
        //Do your calculations here
        CalculationsFunction(param1, param2)
        //Cannot access UI elements here
    };
//Will fire when backgroundworker finishes
bw.RunWorkerCompleted += (s, arg) =>
    {
        //Can access the UI here again if needed
        if (arg.Error != null)
        {
            //Show message if error
        }
        else
        {
            //Update UI here if needed
        }               
    };
    //Begins running the background worker
    bw.RunWorkerAsync((this.DataContext as Iteration));

I think the calculations are freezing up the UI thread. Put the calculations in a BackgroundWorker so the UI can be updated as the calculations are being processed.

var bw = new BackgroundWorker();
//Will fire when backgroundworker starts
bw.DoWork += (snd, arg) =>
    {
        //Do your calculations here
        CalculationsFunction(param1, param2)
        //Cannot access UI elements here
    };
//Will fire when backgroundworker finishes
bw.RunWorkerCompleted += (s, arg) =>
    {
        //Can access the UI here again if needed
        if (arg.Error != null)
        {
            //Show message if error
        }
        else
        {
            //Update UI here if needed
        }               
    };
    //Begins running the background worker
    bw.RunWorkerAsync((this.DataContext as Iteration));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文