各位高手帮忙看下以下代码,多线程跨类对控件赋值控件没有显示值呢?在同一类里面控件就能显示,帮帮忙看下问题出现在哪,程序没有报错
public partial class PhotoMain : Form
{
/开始执行
private void button_ceshi_Click(object sender, EventArgs e)
{
GETI premierLeague = new GETI();
Thread threads = new Thread(delegate() { premierLeague.sss(); });
threads.Name = "PremierLeague";
threadlist.Add(threads);
threads.Start();
}
delegate void PhotoSta(string PhotoSum, string ImgSum, string CJ); /// <summary>
/// 更新状态栏
/// </summary>
public void ThisKeyWords(string PhotoSum, string ImgSum, string CJ)
{
lock (thisLock)
{
try
{
if (this.statusBar_Photo.InvokeRequired)
{ PhotoSta d = new PhotoSta(ThisKeyWords);
this.Invoke(d, new object[] { PhotoSum, ImgSum, CJ });
}
else
{
if (PhotoSum != null)
{
this.statusBar_Photo.Panels[0].Text = PhotoSum;
}
if (ImgSum != null)
{
this.statusBar_Photo.Panels[1].Text = ImgSum;
} if (CJ != null)
{
this.statusBar_Photo.Panels[2].Text = CJ;
}
}
}
catch (Exception ex) { error.LogError("Photo更新状态栏出错:", ex); }
}
}} public class GETI
{
public void sss()
{
PhotoMain ww = new PhotoMain();
ww.ThisKeyWords(null, null, "显示停止!");
}
}
public partial class PhotoMain : Form
{
/开始执行
private void button_ceshi_Click(object sender, EventArgs e)
{
GETI premierLeague = new GETI();
Thread threads = new Thread(delegate() { premierLeague.sss(); });
threads.Name = "PremierLeague";
threadlist.Add(threads);
threads.Start();
}
delegate void PhotoSta(string PhotoSum, string ImgSum, string CJ); /// <summary>
/// 更新状态栏
/// </summary>
public void ThisKeyWords(string PhotoSum, string ImgSum, string CJ)
{
lock (thisLock)
{
try
{
if (this.statusBar_Photo.InvokeRequired)
{ PhotoSta d = new PhotoSta(ThisKeyWords);
this.Invoke(d, new object[] { PhotoSum, ImgSum, CJ });
}
else
{
if (PhotoSum != null)
{
this.statusBar_Photo.Panels[0].Text = PhotoSum;
}
if (ImgSum != null)
{
this.statusBar_Photo.Panels[1].Text = ImgSum;
} if (CJ != null)
{
this.statusBar_Photo.Panels[2].Text = CJ;
}
}
}
catch (Exception ex) { error.LogError("Photo更新状态栏出错:", ex); }
}
}} public class GETI
{
public void sss()
{
PhotoMain ww = new PhotoMain();
ww.ThisKeyWords(null, null, "显示停止!");
}
}
解决方案 »
- 急、急、急!!!!!!!!
- 如何重写控件的属性?
- 【在线等,急!】对获得的中文数据的首字母,按要求进行排列
- 谁来救救我,严重的种族歧视呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 北京软件公司工作模式
- listview中的行如何定位?
- .net中怎么把xmlspy软件生成的xml文件用他的xsl读取啊
- 一段vb.net 改写成 c# 代码的 出现的问题 请高手 帮帮我
- 还是关于autodraw的问题!!
- vb如何调用c#开发的web项目中/bin目录下的.dll文件中的函数。
- webbrowser怎么判断文件是否加载完成
- 急求!求指导!想做个窗体程序借助NPOI用C#把excel导入mysql数据库(VS2010)
{
photoMain.ThisKeyWords(null, null, "显示停止!");
}
{
GETI premierLeague = new GETI();
Thread threads = new Thread(delegate() { premierLeague.sss(this); });
threads.Name = "PremierLeague";
threadlist.Add(threads);
threads.Start();
}
string[] strs=new string[3];
strs[0] = "PhotoSum"; strs[1] = "ImgSum"; strs[2] = "CJ";
threads.Start(strs); delegate void PhotoSta(object o); public void ThisKeyWords(object o)
{
string[] strs = (string[])o;
string PhotoSum = strs[0]; string ImgSum = strs[1]; string CJ = strs[2]; if (this.statusBar_Photo.InvokeRequired)
{ PhotoSta d = new PhotoSta(ThisKeyWords);
this.Invoke(d, new object[] { PhotoSum, ImgSum, CJ });
}
else
{
if (PhotoSum != null)
{
this.statusBar_Photo.Panels[0].Text = PhotoSum;
}
if (ImgSum != null)
{
this.statusBar_Photo.Panels[1].Text = ImgSum;
} if (CJ != null)
{
this.statusBar_Photo.Panels[2].Text = CJ; } }
}
/// 更新状态栏
/// </summary>
public void ThisKeyWords(string PhotoSum, string ImgSum, string CJ)
{
lock (thisLock)
{
try
{
if (this.statusBar_Photo.InvokeRequired)
{ PhotoSta d = new PhotoSta(ThisKeyWords);
this.Invoke(d, new object[] { PhotoSum, ImgSum, CJ });//执行到这卡死了,有没有解决方法吗?
}
else
{
if (PhotoSum != null)
{
this.statusBar_Photo.Panels[0].Text = PhotoSum;
}
if (ImgSum != null)
{
this.statusBar_Photo.Panels[1].Text = ImgSum;
} if (CJ != null)
{
this.statusBar_Photo.Panels[2].Text = CJ;
}
}
}
catch (Exception ex) { error.LogError("Photo更新状态栏出错:", ex); }
}
}}