调度员问题

扫码查看
本文介绍了调度员问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用启动时,我有两个后台工作人员开始工作.

I have two backgroundworker start work when app start up .

一个A将花费5秒,另一个B将花费3秒.

One A will cost 5 seconds, The other B will cost 3 seconds.

A不会影响主UI,但是在加载B时,UI看起来像冻结了.

A will not influence the main UI , but when load B ,the UI will looks like freezed .

例如:加载B时,主RibbonMenu不会引发鼠标悬停事件.用户界面不会突出显示.

For example : when load B ,the Main RibbonMenu will not raise mouse hover event . The UI will not highlight.

在A和B中,我都调用了一些control.Dispacther.BeginInvoke方法,以在BackgroundWorker_Completed事件的主UI中显示一些文本.

Both in A and B , I called some control.Dispacther.BeginInvoke methods to display some text in the main UI in the BackgroundWorker_Completed event. 

我的问题是:为什么A和B是同一背景工作人员,但他们会有不同的作用?

My question is : why A and B are same backgroundworker ,but they will have different effect ?

我只希望后台工作人员或调度员不会延迟主UI的加载时间.

I just want to the background worker or dispatcher will not delay the load time of main UI .

 

 

 

推荐答案

您是否在后台工作程序A完成事件中尝试过为后台工作程序B吃午餐.以这种方式,两个线程都无法同时调用相同的函数.

Did you tried lunching Background worker B in completed event of Background Worker A. In this way there is no way that the both thread will call the same function at the same time.


这篇关于调度员问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 00:03
查看更多