前端之家收集整理的这篇文章主要介绍了
[VB.NET]关于多线程和截图保存的问题!,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
关于多线程和截图保存的问题! 问题是这样的,以下的几行
代码,如果我在form_load事件中就能正常运行,而当我用多线程,单独创建一个线程运行时,老是会在第四行处,
提示"未将对像引用设置到对像实例" 请问,这到底是怎么回事呢? My.Computer.Keyboard.SendKeys("^{prtsc}",True) Dim img As Image img = My.Computer.Clipboard.GetImage img.Save("c:/tmp.jpg",System.Drawing.Imaging.ImageFormat.Jpeg) __________________________________________________________________________ 问题是这样的,System.Drawing.Imaging.ImageFormat.Jpeg) __________________________________________________________________________ 晕啊....沉得这么快..自己顶上去先... __________________________________________________________________________ 晕死...没人回答呀.... __________________________________________________________________________ 你的操作跨线程操作了,用委托。 Delegate Sub t1() Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Dim thread As New Thread(AddressOf test) thread.Start() End Sub Sub test() Me.BeginInvoke(New t1(AddressOf t2)) End Sub Sub t2() My.Computer.Keyboard.SendKeys("^{prtsc}",System.Drawing.Imaging.ImageFormat.Jpeg) End Sub __________________________________________________________________________