求大神指点,关于线程的问题
我把一个函数放到主线程里执行,没有任何问题,但是放到一个新的线程里就出错不知道这是为什么???? --------------------编程问答--------------------表达不清楚,我觉得你的函数执行有错也是应该的。 --------------------编程问答-------------------- 要么你贴出来瞅瞅! --------------------编程问答-------------------- 报什么错?是这个吗?http://blog.csdn.net/conmajia/article/details/7831251 --------------------编程问答-------------------- private void menuItem4_Click(object sender, System.EventArgs e)
{
ThreadStart threadStart = new ThreadStart(CreateGraph);
Thread thread = new Thread(threadStart);
thread.Start();
//CreateGraph();
}
private void CreateGraph()
{
MapInfo.Mapping.FeatureLayer nodeLayer = (MapInfo.Mapping.FeatureLayer)this.mapControl1.Map.Layers["Nliaoning"];
MapInfo.Mapping.FeatureLayer lineLayer = (MapInfo.Mapping.FeatureLayer)this.mapControl1.Map.Layers["Rliaoning"];
graph = new Graph(nodeLayer, lineLayer);
long l = DateTime.Now.Ticks;
graph.ConstructGraph();
l = (DateTime.Now.Ticks - l) / 10000;
MessageBox.Show("构建图需要的时间是:" + l + "毫秒");
this.hashGraph = graph.HashGraph;
graph.NodeLoop();
this.nodeCount = graph.NodeCount;
this.nodeName = graph.NodeName;
this.nodeI = graph.NodeI;
} --------------------编程问答-------------------- 以上就是我的代码,当直接执行这个函数的时候没啥问题,但是放在哪个线程里,报错 --------------------编程问答-------------------- this.mapControl1 要委托去异步赋值
--------------------编程问答-------------------- --------------------编程问答-------------------- 6楼可否详细说说 --------------------编程问答-------------------- 来人啊
补充:.NET技术 , C#