后台-插件-广告管理-内容页广告位一(手机)

您现在的位置是:首页 > 开发类 > 问答问答

非界面线程操作控件的问题

2021-07-06 20:23:11问答人已围观

简介 <P><IMG id=Codehighlighter1_22_126_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_22_126_Open_Text').styl

<P><IMG id=Codehighlighter1_22_126_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_22_126_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_22_126_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_22_126_Closed_Text').style.display='inline';" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_22_126_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_22_126_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_22_126_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_22_126_Open_Text').style.display='inline';" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;DoWork()&nbsp;</SPAN><SPAN id=Codehighlighter1_22_126_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG alt="" src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_22_126_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread&nbsp;t&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;Thread(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;ThreadStart(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.DoSomething));<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.Start();<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_162_218_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_162_218_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_162_218_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_162_218_Closed_Text').style.display='inline';" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_162_218_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_162_218_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_162_218_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_162_218_Open_Text').style.display='inline';" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;DoSomething()&nbsp;</SPAN><SPAN id=Codehighlighter1_162_218_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG alt="" src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_162_218_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">thread&nbsp;start</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN></P> <P><SPAN><SPAN style="COLOR: #000000">如上代码,有个疑问,不是说对界面控件的更新是要在主线程上操作的吗?那为什么在新开的线程上也能操作啊,不太明白其中的道理,高手请指点</SPAN></SPAN></P>

最佳答案:所有在主线程上创建的控件,必须在主线程上进行操作 就是说,不能从一个线程操作在别的线程上创建的控件 你的代码里,MessageBox是在DoSomeThing的线程上创建的,因此没问题吧……

文章来源:https://q.cnblogs.com/q/2613/

Tags:.net技术 c 

很赞哦! ()

后台-插件-广告管理-内容页广告位二(手机)

相关文章

后台-插件-广告管理-内容页广告位三(手机)
后台-插件-广告管理-内容页广告位四(手机)

文章评论

留言与评论(共有 0 条评论)
   
验证码:

本栏推荐

站点信息

  • 文章统计90180篇文章
  • 浏览统计10086次浏览
  • 评论统计1个评论
  • 标签管理标签云
  • 统计数据:统计代码
  • 微信公众号:扫描二维码,关注我们