我有一个订阅事件的方法(来自SDK)。如果触发该事件,则该方法始终会运行到“调用所需”表达式中。这是否意味着该事件在另一个线程上执行?事件通常如何做到这一点?我是活动的新手,请解释一下。非常感谢!
void TrackingOnNewTrackingObservations(object sender, TrackingEventArgs e)
{
try
{
if (!dgvTracking.InvokeRequired)
{
dgvTracking.Rows[0].Cells["cName"].Value = "SlopeDistance";
dgvTracking.Rows[0].Cells["cValue"].Value = string.Format("{0:0.00} m", e.SlopeDistance);
dgvTracking.Rows[1].Cells["cName"].Value = "HorizontalAngle";
dgvTracking.Rows[1].Cells["cValue"].Value = string.Format("{0:0.00000}°", e.HorizontalAngle);
dgvTracking.Rows[2].Cells["cName"].Value = "VerticalAngle";
dgvTracking.Rows[2].Cells["cValue"].Value = string.Format("{0:0.00000}°", e.VerticalAngle);
}
else
{
Debug.WriteLine("Invoke needed");
}
}
catch (Exception ex)
{
Debug.WriteLine("Error TrackingOnNewTrackingObservations ->" + ex.Message);
}
}