Monitor.Enter,可以在新线程里修改UI控件的属性吗?
void ThreadRunFunction()
{
MyWebRequest request = null;
while(ThreadsRunning && int.Parse(Thread.CurrentThread.Name) < this.ThreadCount)
{
MyUri uri = DequeueUri();
if(uri != null)
{
if(SleepConnectTime > 0)
Thread.Sleep(SleepConnectTime*1000);
ParseUri(uri, ref request);
}
else
Thread.Sleep(SleepFetchTime*1000);
}
Monitor.Enter(this.listViewThreads);
try
{
ListViewItem item = this.listViewThreads.Items[int.Parse(Thread.CurrentThread.Name)];
if(ThreadsRunning == false)
item.SubItems[2].Text = "Stop";
item.ImageIndex = 0;
}
catch(Exception)
{
}
Monitor.Exit(this.listViewThreads);
}
如题,这个是新开线程的启动函数,怎么没有用Invoke委托,修改UI控件的属性呢?路过的帮看一下!谢谢! --------------------编程问答-------------------- 自己顶 --------------------编程问答-------------------- 有人吗
--------------------编程问答-------------------- 不行.
跨线程操作UI控件需要Invoke
补充:.NET技术 , C#