C#与Halcon实时显示相机画面`
private async void btnRunning_Click(object sender, EventArgs e)
{
isRunning = true;
Cam1.OpenCam();
task[0]=Task.Factory.StartNew(() =>
{
while (isRunning)
{
Cam1.GrabImage();
hWindow_Final1.HobjectToHimage(Cam1.ho_Image);
Thread.Sleep(10);
label3.BeginInvoke(new Action(()=> { label3.Text = DateTime.Now.ToString(); }));
}
});
await task[0];
}
private void btnStop_Click(object sender, EventArgs e)
{
isRunning = false;
Cam1.CloseCam();
}
async await
label3.BeginInvoke(new Action(()=> { label3.Text = DateTime.Now.ToString(); }));