简体   繁体   English

Visual C#多线程UserControl DLL

[英]Visual C# Multithreaded UserControl DLL

I would like to create a multithreaded Usercontrol with C#. 我想用C#创建一个多线程用户控件。 Is this possible with VisualStudio or only in C++? 使用VisualStudio或仅在C ++中可能吗? The idea behind is to initiate several instances of the control, so that each instance has its own memory segments and works inependent from the other instances... 背后的想法是启动控件的多个实例,以便每个实例都有自己的内存段,并且与其他实例无关...

Background: 背景:
I would like to use the control within SAP. 我想在SAP中使用控件。 In SAP I am able to create multiple instances of SAP GUI. 在SAP中,我可以创建多个SAP GUI实例。 Each SAP GUI instance contains my own (ActiveX) control. 每个SAP GUI实例都包含我自己的(ActiveX)控件。 The example is a stop watch. 该示例是秒表。 Currently i start the stop watch in the first instance and all other instances are in sync. 目前,我是在第一个实例中启动秒表,所有其他实例都处于同步状态。 This is fine so far - but now I would like to change the UserControl (which is obviously a STA DLL) to an MTA DLL so that each instance of the control has its own time... Do I have any chance to compile it as an MTA DLL or is this not solving the issue (without changing the architecure)? 到目前为止,这还不错-但现在我想将UserControl(显然是STA DLL)更改为MTA DLL,以便控件的每个实例都有自己的时间...我有没有机会编译为一个MTA DLL还是不能解决问题(无需更改架构)? Or am I completly wrong? 还是我完全错了?

Assumption: The stopwatch is GDI based... The actual error which I am seeing is from code inside GDI+ that ensures the same Graphics object cannot be used in multiple threads. 假设:秒表是基于GDI的...我看到的实际错误是来自GDI +中的代码,该代码确保了同一Graphics对象不能在多个线程中使用。 But how can I use the graphics object in multiple threads? 但是,如何在多个线程中使用图形对象?

Base on the info you provided, yes you can, but for memory segment, its per process not controls inside the process, for 32-bit applications, max is 2GB, can be extended to 3GB but not recommended. 根据您提供的信息,可以,但是对于内存段,其每个进程均不受进程内部控制,对于32位应用程序,最大为2GB,可以扩展为3GB,但不建议这样做。

if you want independent memory then you must create multiple executables where each exe has its own address space. 如果要独立的内存,则必须创建多个可执行文件,其中每个exe文件都有其自己的地址空间。

so what you can do is create a C# application that has usercontrol or form and add your logic, this will be compiled into a separate exe, then create another C# application to start a process(es) for the first C# application. 因此,您可以做的是创建一个具有用户控制或窗体的C#应用​​程序,并添加您的逻辑,这将被编译成一个单独的exe,然后创建另一个C#应用程序以启动第一个C#应用程序的进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM