首页 \ 问答 \ C#将类实例存储在数组中以用于其他形式(C# Storing class instances in an array to use in other forms)

C#将类实例存储在数组中以用于其他形式(C# Storing class instances in an array to use in other forms)

所以我有我自己的类,我想通过按钮点击类存储类的一个实例,然后在同一个项目下以不同的形式使用这个数组,但尽管声明为公共静态我仍然无法访问它在我的其他形式。 我甚至试图把它放入课堂本身来看看是否可行。 我听说你可以使用列表数组,但我不知道我将如何做,并再次如何访问它在我的整个项目。

对不起,如果我错过了明显的东西,或者我对C#相当陌生。


So i have my own class and i want to store an instance of the class by button click into a class array and then use this array in a different form under the same project however despite declaring it as public static i still can't access it on my other form. I have even tried putting it into the class itself just to see if that would work. I have heard you can use a list array but i am not sure how i would do that and again how to access it over my whole project.

Sorry if i missed something obvious or anything I'm fairly new to C#.


原文:https://stackoverflow.com/questions/40631540
更新时间:2022-03-22 16:03

最满意答案

应该只有一个线程操作GUI(对于任何GUI框架都是如此)。 您应该组织代码,以便cvShowImage主“GUI线程”调用cvShowImage

看来在query_thread中完成的工作可以在主线程中轻松完成。


There should only be one thread manipulating the GUI (this is true for just about any GUI framework). You should organize your code so that cvShowImage is only invoked from the main "GUI thread".

It seems that the work that's being done in query_thread could just as easily be done inside the main thread.

相关问答

更多
  • 澄清一下,你使用C还是C ++? 如果您使用C ++,请使用OpenCV的C ++接口。 下面的例子适用于我: #include int main() { //initialize and allocate memory to load the video stream from camera cv::VideoCapture camera0(0); cv::VideoCapture camera1(1); if( !camer ...
  • 我想出来了。 当我在VLC中打开捕获时,我注意到它将文件名与v4l2:// 。 当我在我的应用程序中做同样的事情时,它工作了! 因此,要在上面引用, "/dev/my_custom_name"应该变为"v4l2:///dev/my_custom_name" 。 I figured this out. When I opened the capture in VLC, I noticed that it preixed the filename with v4l2://. When I did the sam ...
  • 应该只有一个线程操作GUI(对于任何GUI框架都是如此)。 您应该组织代码,以便cvShowImage主“GUI线程”调用cvShowImage 。 看来在query_thread中完成的工作可以在主线程中轻松完成。 There should only be one thread manipulating the GUI (this is true for just about any GUI framework). You should organize your code so that cvShowI ...
  • 每个网络摄像头都连接到不同的USB端口? 如果是这样,它很好。 即使它只有1个端口,4个连接的网络摄像头。 我不认为4 320x240也会有任何问题。 USB 2.0 = 320Mbps 。 流式传输320x240视频不会超过1mbps。 最糟糕的情况是,将320x240放在2mbps + 1mb的其他数据上。 这将是你的usb端口和设备之间的12mbps带宽。 因此,从上面看,1个USB端口可以处理由分路器连接的4个网络摄像头,速度与1 640x480网络摄像头一样快。 处理这些图像取决于您的计算机速度以 ...
  • 您或许可以使用未来 。 您可以将未来视为线程之间的共享值。 一个线程将写入未来的值,另一个线程将读取它。 如果尚未编写未来,则读取线程将阻塞,直到它具有。 期货已经成为boost.threads的一部分。 You may be able to use a future. You can think of a future as a shared value between threads. One thread will write the value of the future and another t ...
  • 我不使用boost很多,但是你不需要做一些事情来保持main()在你的线程工作时退出吗? 就像也许...... int main() { boost::thread trackerThread( boost::bind(openCamera) ); trackerThread.join(); } I don't use boost a lot, but don't you need to do something to keep main() from exiting while your ...
  • 你不能。 一次只能有一个应用程序可以访问任何设备 - 即使使用常见的I / O设备(如硬盘)也是如此。 如果多个应用程序可以同时访问设备,则会混淆其遵循的说明。 但是,您可以使用SplitCam。 它将连接到网络摄像头(没有其他应用程序可以)。 但它将创建其他应用程序可以连接的虚拟设备。 You can't. Only one application can access any device at a time - even with common I/O devices like hard disks. ...
  • 这个可以吗? 是的,就是这样。 是否有另一种方法来分割屏幕而不重复对象? 你不是在复制对象。 你不能,因为在OpenGL中没有“对象”这样的东西。 OpenGL只是一种在帧缓冲区上绘制的复杂铅笔。 没有场景,没有物体,只有点,线和三角形绘制到帧缓冲区。 你所要做的就是从不同的角度画出几张相同的东西,就像你想用纸笔做的那样。 Is this okay? Yes, that's how it goes. Is there another way to split the screen without dupli ...
  • 我在OSX上使用Python时遇到了这个问题。 我的解决方案是使用--with-ffmpeg标志重建opencv。 I just had this exact problem using Python on OSX. The solution for me was to rebuild opencv using the --with-ffmpeg flag.
  • 我从你的标签看到你正在使用Qt。 因此,我建议使用QThreads,如果你还没有,因为他们使很多事情变得更容易。 使用QThreads时,您创建一个为每个辅助线程继承QObject的类。 至于线程的数量,我认为你会想要至少3(主要或用户界面,视频和串行端口)。 你可以做更多,但我不会,除非你有特定的需求(例如,我经常使用2个助手线程的视频,一个捕获和一个处理)。 我建议在信号和插槽的线程之间进行通信,而不是直接调用函数。 有许多方法可以使用不同的ConnectionTypes在Qt中的线程之间进行连接 。 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)