C # Real-time dynamic refresh list [such as Datagridview,listview

Source: Internet
Author: User

ThreadPool.QueueUserWorkItem (_ =>

{

This. Invoke (MethodInvoker) (() =>

{

Try

{

Lock (M_OBJLOCK5)

{

if (Evis.count!= evss.count) return; Exception occurred, return does not extract

foreach (Entityvehicleinfo evi in Evis)

{

int mcuid = Evi. Mcuid;

Add Geographic information

Entityvehicleinfo vehicleinfo = null;

Vehicleinfo = Datareader.instance.htvehicleinfo[mcuid]asentityvehicleinfo;

if (Vehicleinfo = null) return;

int add_infoindex = DGVVEHICLEINFO.ROWS.ADD (1);

DataGridViewRow row = Dgvvehicleinfo.rows[add_infoindex];

Dituhelper.getaddressbygps (Vehicleinfo.longitude, Vehicleinfo.latitude, Add_infoindex);

Row. cells["Vehicleinfomcuid"]. Value = Vehicleinfo.mcuid;

Row. cells["Vehicleno"]. Value = Vehicleinfo.vehicleno;

Row. cells["ONLINE"]. Value = Vehicleinfo.online;

Row. cells["ACC". Value = VEHICLEINFO.ACC;

Row. cells["Longitude"]. Value = vehicleInfo.Longitude.ToString ("F5");

Row. cells["LATITUDE"]. Value = vehicleInfo.Latitude.ToString ("F5");

Row. cells["ANGLE"]. Value =utilityhelper.angle2direction ((int) vehicleinfo.angle);

Row. cells["VELOCITY"]. Value = vehicleinfo.velocity;

Row. cells["Locationstate"]. Value = vehicleinfo.locationstate;

Row. cells["Receivetime"]. Value = Vehicleinfo.receivetime;

Add status information

Entityvehiclestate vehiclestate = null;

Vehiclestate = datareader.instance.htvehiclestate[mcuid]asentityvehiclestate;

if (vehiclestate = null) return;

int add_stateindex = DGVVEHICLESTATE.ROWS.ADD (1);

DataGridViewRow row2 = Dgvvehiclestate.rows[add_stateindex];

Row2. cells["Vehiclenos"]. Value = VehicleInfo.VehicleNo.ToString ();

Vehicleinfo = null;

Row2. cells["Positiontime"]. Value = VehicleState.PositionTime.ToString ();

Row2. cells["Stopfuel"]. Value = Vehiclestate.stopfuel? " Yes ":" No ";

Row2. cells["Fuelcut"]. Value = Vehiclestate.fuelcut? "Oil power Off": "Through oil and electricity";

Row2. cells["Autodefence"]. Value = vehiclestate.autofence? " Fortification ":" To Prevent ";

Row2. cells["Trunkboot"]. Value = Vehiclestate.trunkboot? " Open ": Close";

Row2. cells["braking"]. Value = vehiclestate.braking? "Brake down": "Brake release";

Row2. cells["Dooropen"]. Value = Vehiclestate.dooropen? "Open": "Close";

Row2. cells["Accon"]. Value = Vehiclestate.accon? "Ignition": "flameout";

Row2. cells["Powersaver"]. Value = Vehiclestate.powersaver? " Yes ":" No ";

Vehiclestate = null;

}

}

}

catch (Exception ex)

{

Loghelper.writeln ("Instance_notifyinfo" + Ex.) StackTrace);

}

}));

});

The effect is as follows:

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.