Solving the phenomenon of "suspended animation" in Arcengine development program

Source: Internet
Author: User

In the process of GIS data processing, the large amount is a very nerve-racking problem. Recently, this problem was encountered when writing a CAD note to a shapefile file.

once processed data, up to 1.3 million points, that is, the test area of the grid into point all processing, the program is written well, but the speed of the slow ah, the key problem is to deal with the half report strange error, finally had to divide the data into 6 parts, to the laboratory opened 6 machines to separate processing, and finally synthesized together. after this, I went to ask the teacher, they are in the process of processing GIS big data (especially when the data with spatial information), how to solve similar problems? He summed up two aspects: first, the hardware, the configuration is high, for particularly large data to consider the use of workstations or servers to handle, GIS processing is easy to encounter this situation, the second is the code, to constantly optimize, should not new do not new, can save the province, write more memory and space-saving code, Need to accumulate and learn constantly.

For users, they absolutely can not tolerate "suspended animation phenomenon", a click on the "Submit" program interface is stuck, if forced into the drag interface is prone to unresponsive, until the program is closed.

As a result of his non-computer professional origins, the problem is helpless, the online solution is multi-threading, so I try to do this:

Thread mythreadone = new Thread (new ThreadStart (Main)); Mythreadone.name = "Cadtoshapethread"; Mythreadone.isbackground = true; Mythreadone.start ();

Put the original directly written code in a main function, and then create a new thread call main, the result is much better, the program interface can be dragged, the data in the background processing. But due to the lack of understanding of threads and processes, its security issues need to be resolved, to study this magical thing.

In order to let the user know that the program is still processing, there is no result, there is a progress bar: When the process starts, the progress bar appears, and constantly scroll to display; When the process ends, the progress bar is hidden.

But I failed to access the properties in the process to set the progress bar, error: "Cross-thread operation not Valid:control ' progressBar1 ' accessed from a thread other than the THR EAD it was created on. " Baidu said, this is not safe, to use the Commission to solve, commissioned? If you don't understand it, you have to make a mistake. Here's the Final Solution:

<summary>///Setting Control parameters///</summary>///<param name= "Ocontrol" > Controls </param>///<param name= "PropName" > Parameter name </param>///<param name= "propvalue" > Parameter value </param>delegate void Setcontrolvaluecallback (Control Ocontrol, String propname, Object propvalue);p rivate void Setcontrolpropertyvalue ( Control Ocontrol, String propname, Object PropValue) {if (ocontrol.invokerequired) {Setcontrolvaluecallback        D = new Setcontrolvaluecallback (setcontrolpropertyvalue);    Ocontrol.invoke (d, new object[] {ocontrol, propname, propvalue});        } else {Type t = ocontrol.gettype ();        system.reflection.propertyinfo[] props = t.getproperties ();            foreach (System.Reflection.PropertyInfo p in props) {if (p.name.toupper () = = Propname.toupper ())            {P.setvalue (Ocontrol, propvalue, NULL); }        }    }}

Solving the phenomenon of "suspended animation" in Arcengine development program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.