c# 多线程加载Vpp
虽然没报错,但是感觉没啥用
放上代码 等以后再来看看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Cognex.VisionPro.QuickBuild; using Cognex.VisionPro; using System.Threading; namespace 缺陷检测1._0 { public partial class Form1 : Form { static CogJobManager myManager; public Form1() { InitializeComponent(); } //直接加载vpp private void button1_Click(object sender, EventArgs e) { myManager = (CogJobManager)CogSerializer.LoadObjectFromFile(@"C:\Users\Administrator\Desktop\视觉训练\缺陷检测测试\孔隙检测2.0.vpp"); cogJobManagerEdit1.Subject = myManager; } //多线程加载vpp /* private void button1_Click(object sender, EventArgs e) { InsertVpp(); cogJobManagerEdit1.Subject = myManager; } private delegate void CallInsertVpp(); void InsertVpp() { UseVpp uv = new UseVpp(); if (this.button1.InvokeRequired) { CallInsertVpp call = new CallInsertVpp(uv.useVpp); this.button1.Invoke(call); } else { uv.useVpp(); } } class UseVpp { public void useVpp() { myManager = (CogJobManager)CogSerializer.LoadObjectFromFile(@"C:\Users\Administrator\Desktop\视觉训练\缺陷检测测试\孔隙检测2.0.vpp"); } }*/ } }
放两个链接
在多线程中调用winform窗体控件的实现方法
https://www.jb51.net/article/54187.htm