小编Ryd*_*der的帖子

如何等待后台工作者完成处理?

我有3个后台工作人员,每个工作人员处理一个24位位图图像(Y,Cb,Cr)的通道.每个8位图像的处理需要几秒钟,并且它们可能无法同时完成.

我想在完成后将频道合并为一个图像.单击一个按钮时,每个按钮都会backgroundWorkerN.RunWorkerAsync()启动,当它们完成时,我会设置一个标志为true.我尝试使用while循环while (!y && !cb && !cr) { }来连续检查标志,直到它们为真,然后退出循环并继续处理下面的代码,这是将通道合并回来的代码.但是当我运行它时,过程永远不会结束.

   private void button1_Click(object sender, EventArgs e)
   {
        backgroundWorker1.RunWorkerAsync();
        backgroundWorker2.RunWorkerAsync();
        backgroundWorker3.RunWorkerAsync();

        while (!y && !cb && !cr) { }

        //Merge Code
   }
Run Code Online (Sandbox Code Playgroud)

c# parallel-processing backgroundworker winforms

4
推荐指数
1
解决办法
8742
查看次数

Javascript函数参数必须是一个字符串?

我是javascript的新手,所以我不确定为什么它会像这样.

我有一个时钟功能:

function updateClock()
{
var currentTime = new Date();

var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
var currentMilliseconds = currentTime.getMilliseconds();

// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? …
Run Code Online (Sandbox Code Playgroud)

javascript

3
推荐指数
1
解决办法
208
查看次数