Reputation: 41
I would like to create a multithreaded Usercontrol with C#. Is this possible with VisualStudio or only in 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. In SAP I am able to create multiple instances of SAP GUI. Each SAP GUI instance contains my own (ActiveX) control. 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)? 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. But how can I use the graphics object in multiple threads?
Upvotes: 0
Views: 202
Reputation: 521
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.
if you want independent memory then you must create multiple executables where each exe has its own address space.
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.
Upvotes: 1