求高手帮助,看个程序,不知道为什么错误??
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;
}
上面的CreateGraph()放到主线程中运行没有错误,但是放到一个新建的线程里就出错, --------------------编程问答-------------------- 查询语句出错了?
无效的Rliaoning? --------------------编程问答-------------------- 不是查询语句的问题吧,为什么放到主线程里就没错误了呢?? --------------------编程问答-------------------- --------------------编程问答-------------------- 访问了主进程中的mapcontrol组建,是因为这个吗,怎么解决呢???
补充:.NET技术 , C#