跨线程图片盒pointtoscreen

编程入门 行业动态 更新时间:2024-10-14 14:15:39
本文介绍了跨线程图片盒pointtoscreen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Using bitmap As New Bitmap(CameraView.Width, CameraView.Height) Using g As Graphics = Graphics.FromImage(bitmap) ' Get the paramters to call g.CopyFromScreen and get the image Dim rectanglePanelVideoPreview As Rectangle = CameraView.Bounds Dim sourcePoints As System.Drawing.Point = CameraView.PointToScreen(New System.Drawing.Point(CameraView.ClientRectangle.X, CameraView.ClientRectangle.Y)) g.CopyFromScreen(sourcePoints, System.Drawing.Point.Empty, rectanglePanelVideoPreview.Size) End Using End Using

i希望使用backgroundworker来执行该代码,但因使用PointToScreen而出现错误。 请帮我重新编写跨线程代码。 Thx

i want to use backgroundworker to do that code, but got error because use PointToScreen. Please help me re-code with cross-thread. Thx

推荐答案

实际绘图必须在UIThread中完成。这是运行应用程序和处理用户界面的主线程。您需要告诉UI线程调用该方法,以便允许它进行屏幕更新。在后台工作者中,您只能在实际绘图之前完成所有工作。完成工作后,您将调用更新UI的方法。该方法应检查是否需要调用,这意味着另一个线程正在调用该方法,它将自动调用自己在UI线程上执行。 Actual drawing must be done in the UIThread. This is the main thread running the application and handling the user interface. You need to tell the UI Thread to invoke the method so it is allowed to do screen updates. In the backgroundworker you would only do all the work prior to the actual drawing. When the work is done you then invoke a method that updates the UI. That method should check if an invoke is required, meaning that is another thread is calling the method, it will automatically invoke itself to be executed on the UI thread. If Me.InvokeRequired Then Me.Invoke(New MethodInvoker(AddressOf AccessControl)) Else

查看此链接了解更多信息: msdn.microsoft/en -us / library / ms171728%28v = vs.85%29.aspx?cs-save-lang = 1& cs-lang = vb#code-snippet-1 [ ^ ] 祝你好运!

Check this link for more info: msdn.microsoft/en-us/library/ms171728%28v=vs.85%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1[^] Good luck!

更多推荐

跨线程图片盒pointtoscreen

本文发布于:2023-11-07 00:06:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   图片   pointtoscreen

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!