vb.net 如何通过byref 将结构传递给线程? [英] vb.net how to pass structure to thread by byref?

查看:29
本文介绍了vb.net 如何通过byref 将结构传递给线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将结构引用传递到线程时出现构建错误.

I get a build error when I try to pass a structure reference into a thread.

dim antenna_frame_buffer as Antenna_Frame_Buffer_structure
...

new_buffer_write_thread = new Thread( AddressOf frame_buffer_write_Thread )
new_buffer_write_thread.Start( antenna_frame_buffer )   

...

    sub frame_buffer_write_Thread( ByRef antenna_frame_buffer as Antenna_Frame_Buffer_structure ) 
...

错误...

严重性代码描述项目文件行抑制状态错误 BC30518 重载解析失败,因为没有可访问的新"可以使用这些参数调用:'Public Overloads Sub New(start As ThreadStart)':方法'Public Sub frame_buffer_write_Thread(ByRef天线_frame_buffer AsEmbedded_Communication_Interface.Antenna_Frame_Buffer_structure)' 确实没有与委托 'Delegate Sub 兼容的签名线程开始()'.'Public Overloads Sub New(start As ParameterizedThreadStart)':方法'Public Sub frame_buffer_write_Thread(ByRef)天线帧缓冲区作为Embedded_Communication_Interface.Antenna_Frame_Buffer_structure)' 确实没有与委托 'Delegate Sub 兼容的签名ParameterizedThreadStart(obj As Object)'.SYS HUB 和硬件图形界面 C:\PRIMARY\WORK\SYSTEMHUB\SOURCE\Embedded_Communication_Interface.vb 1030 活动

Severity Code Description Project File Line Suppression State Error BC30518 Overload resolution failed because no accessible 'New' can be called with these arguments: 'Public Overloads Sub New(start As ThreadStart)': Method 'Public Sub frame_buffer_write_Thread(ByRef antenna_frame_buffer As Embedded_Communication_Interface.Antenna_Frame_Buffer_structure)' does not have a signature compatible with delegate 'Delegate Sub ThreadStart()'. 'Public Overloads Sub New(start As ParameterizedThreadStart)': Method 'Public Sub frame_buffer_write_Thread(ByRef antenna_frame_buffer As Embedded_Communication_Interface.Antenna_Frame_Buffer_structure)' does not have a signature compatible with delegate 'Delegate Sub ParameterizedThreadStart(obj As Object)'. SYS HUB and HW GUI C:\PRIMARY\WORK\SYSTEM HUB\SOURCE\Embedded_Communication_Interface.vb 1030 Active

推荐答案

结构不能通过引用传递给线程.然而,幸运的是,类的对象可以通过引用传递.

Structure cannot be passed by reference to a thread. However, and fortunately, an object of a class CAN be passed by reference.

这篇关于vb.net 如何通过byref 将结构传递给线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆