CheckForIllegalCrossThreadCalls = false;//允许线程交叉管理
或者是 你直接就把 this 传递过去 将UI线程直接扔过去,,给他绝对的控制权
或者通过 委托 自己写一个方法 将委托扔过去 通过委托来调用方法 3种方法最少有2个应该是可行的,,你可以试下
或者是 你直接就把 this 传递过去 将UI线程直接扔过去,,给他绝对的控制权
或者通过 委托 自己写一个方法 将委托扔过去 通过委托来调用方法 3种方法最少有2个应该是可行的,,你可以试下
解决方案 »
- 新手问题:如何自定义类以及如何使用它
- 如何给1列数据赋相同的值?
- 急:谁有"IP*Wroks! v6 .net"的系列号,我下的一个V6.1550不能安装.
- DataGridBoolColumn问题???请大家帮忙看看!
- 大家知道怎么实现qq那种头像循环吗? c/s模式的。好像用datagrid这种也不能那样做呀! c/s下面又没有摸版列
- 如何清屏?
- 请教关于c#.net 服务器与客户端通过TcpClient相互通迅的问题
- 为什么一添加控件,我的程序就出错,看起来不像是IDE出问题,大家帮助我看看,着急....
- 请问我用c#编写了一个程序,要调用数据库(sql),我生成一个应用程序,怎么在别人的机器上运行,都需要什么???要别人的机器也装sql吗?????情说
- 那里有下载Smart Device Extension?
- 大家知道 “主机审计” 都应用什么技术么?我是.net程序员
- 大侠们指点一下吧
{
BackgroundWorker worker = sender as BackgroundWorker;
//表示获取特征结果的值
e.Result = GetBmpFeature(worker, e);
} //特征分析结束,显示图片
void BWAnalysis_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
MessageBox.Show(e.Error.Message);
else if (e.Cancelled)
{
textAnalysis.Text = "特征分析过程终止. . . . . .";
btnCancel.IsEnabled = false;
}
else
{
textAnalysis.Text = "完成"; if (null == bmpFeature || 0 == bmpFeature.Count)
{
MessageBox.Show("特征分析失败,没有检测到人脸。", "操作失败", MessageBoxButton.OK,
MessageBoxImage.Information); //设置按键为不可用
btnLast.IsEnabled = false;
btnNext.IsEnabled = false;
btnGo.IsEnabled = false;
btnOK.IsEnabled = false;
btnLeftEye.IsEnabled = false;
btnRightEye.IsEnabled = false;
btnLeftNaris.IsEnabled = false;
btnRightNaris.IsEnabled = false;
btnLeftMouth.IsEnabled = false;
btnRightMouth.IsEnabled = false;
}
else
{
textAnalysis.Text = "test"; ImageBox.Source = (ImageSource)bmpFeature[0]; //想在这里访问,可是exception说这里“另一线程拥有此对象”
if (1 == this.bmpFeature.Count)
{
this.btnNext.IsEnabled = false;
}
}
}
btnCancel.IsEnabled = false; GetCurrentScreen(ref gridGetCurr);
SetScreenHide(gridGetCurr);
SetScreenVisible(gridModify);
stateManager.CurrentState = StateManager.ScreenStates.ScreenModify;
}
//更新进度条
void BWAnalysis_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar.Value = e.ProgressPercentage;
} //获取人脸特征
private void GetBmpFeature(BackgroundWorker worker, DoWorkEventArgs e)
{
if (worker.CancellationPending)
e.Cancel = true;
for (int i = 0; i < picFileNames.Length; i++)
{
fDataPic = manager.GetFeature(picFileNames[i]);
if (null == fDataPic)
continue;
else
{
Bitmap bmp = this.manager.GetFeaturePicture(fDataPic, picFileNames[i]);
bmpFeature.Add(BmpChange(bmp)); //bmpFeature是我所说的UI的成员:ArrayList对象,在这个耗时的函数里做了修改
bmp.Dispose();
}
int percentComplete = (int)((float)i / (float)bmpFeature.Count * 100);
if (percentComplete > highestPercentageReached)
{
this.highestPercentageReached = percentComplete;
worker.ReportProgress(percentComplete);
}
}
}
label1.Invoke( new MethodInvoker(delegate()
{
label1.Text="lalala";
}));
这种写法会引起FORM崩溃滴,请使用11楼的做法。