C # Real-Time Dynamic Refresh list [such as DataGridView, ListView, etc.

Source: Internet
Author: User

ThreadPool. QueueUserWorkItem (_ =>

{

This. Invoke (MethodInvoker) () =>

{

Try

{

Lock (m_objLock5)

{

If (EVIs. Count! = Evss. Count) return; // if an exception occurs, no extraction is returned.

Foreach (EntityVehicleInfo evi in EVIs)

{

Int mcuid = evi. MCUID;

/// // Add Location 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. longpolling, 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 ["longpolling"]. Value = vehicleInfo. longpolling. 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? "Power-off": "power-off ";

Row2.Cells ["AUTODEFENCE"]. Value = vehicleState. AutoFence? "Fortification": "anti-DDoS ";

Row2.Cells ["TRUNKBOOT"]. Value = vehicleState. TrunkBoot? "Enable": "Disable ";

Row2.Cells ["BRAKING"]. Value = vehicleState. Braking? "Brake on": "brake on 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_policyinfo" + 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.