473,378 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Using STA API in a MTA enviroment

So, here it is:

I have a 3'rd party API written in C that is Single Threaded(state is saved
between different commands, locks and so on - so i'v heared).
The only way i was able to use it is with thread sync:
calss A{
public void b()
{
lock(A){....}
}
But as you realize this kills all performance. The next solution would be to
create multiple processes that load the DLL and communicate between the IIS
and this processes. So far i'v tried remoting with both server and client
activated objects but not with much luck. The only thing that worked was
Process.Start("..") but the process dies after performing a task(ofcourse)
and there is no way to send back information from the created porcess.

The general ideea would be to create multiple processes that can execute the
commands that come from IIS(through MSMQueue or something similar). What it
would be great is to have a bare socket from the IIS to each of the "worker"
processes for sending and reciving data.

What i would like to know is:
If there is a simpler way of doing this whole thing?(already tried
COM+/Enterprise Services and a C++ wrapper that unloads the DLL but didn't
work well)
If not, is there a way to create a communication channel between 2 processes
that doesn't include remoting?(bare sockets or someting - i just want to send
string from one place to another :))

PS: API will not change for the next years... :(
PS2:I know it's stange...

Thank you!
Nov 18 '05 #1
2 2830
Hi Raul:

STA and MTA are related to COM. Are you saying you have an STA COM
object implemented in C ?

If you have an STA component, you don't need to perform any locking on
an object. COM performs the synchronization for you.

What you might need to do however, is set aspcompat="true" in the
@Page directive. If this component is an STA component it causes the
call to move from an MTA thread running the ASP.NET page into the STA
thread your component has an affinity for.

--
Scott
http://www.OdeToCode.com

On Fri, 17 Sep 2004 04:23:03 -0700, "Raul"
<Ra**@discussions.microsoft.com> wrote:
So, here it is:

I have a 3'rd party API written in C that is Single Threaded(state is saved
between different commands, locks and so on - so i'v heared).
The only way i was able to use it is with thread sync:
calss A{
public void b()
{
lock(A){....}
}
But as you realize this kills all performance. The next solution would be to
create multiple processes that load the DLL and communicate between the IIS
and this processes. So far i'v tried remoting with both server and client
activated objects but not with much luck. The only thing that worked was
Process.Start("..") but the process dies after performing a task(ofcourse)
and there is no way to send back information from the created porcess.

The general ideea would be to create multiple processes that can execute the
commands that come from IIS(through MSMQueue or something similar). What it
would be great is to have a bare socket from the IIS to each of the "worker"
processes for sending and reciving data.

What i would like to know is:
If there is a simpler way of doing this whole thing?(already tried
COM+/Enterprise Services and a C++ wrapper that unloads the DLL but didn't
work well)
If not, is there a way to create a communication channel between 2 processes
that doesn't include remoting?(bare sockets or someting - i just want to send
string from one place to another :))

PS: API will not change for the next years... :(
PS2:I know it's stange...

Thank you!


Nov 18 '05 #2
Hi Raul:

I don't think there is any simple solution for you. You could launch a
handful of new processes and then talk to them with remoting, but this
would take some work. COM+ is only going to launch a seperate
processes when it is forced to, for example, to run com servers under
two different security contexts.

One option you might want to consider is queueing. The requests that
need to be processed with this DLL could be queued and finished
asynchronously. You could send the users an email when thier process
is finished. I've never liked this approach from a user experience
point of view, but I think you'll find the design is easier to
maintain and debug when compared to remoting with multiple processes.

Is there anyway to refactor the functionality in the DLL?

--
Scott
http://www.OdeToCode.com
On Fri, 17 Sep 2004 07:35:12 -0700, "Raul"
<Ra**@discussions.microsoft.com> wrote:
No, i'm not using COM, i'm using DLL Import and you are right STA, MTA are
COM therms but what i ment when saying Single Thread is that when i perform 2
actions in the same time my web service dies. So try it's not a COM thing
rather then the concept of Single Threaded(can't work with more threads in
the same time) :)

Yes, aspcompat was one of the first things i tried but i'm using another
class that makes impersonation(again DLL Import but to the Win32 API this
time) and this time the Win API needs a Mutli Threaded enviroment(basicaly
doesn't work with that setting).

My problem is that as long as the DLL is loaded once i need to have
syncronization - so i loose performance(there can be long running tasks that
take 2-3 minutes). So i NEED more processes. There is no way arround it - so
i'v seen until now.

My propblem would be solved if i could make COM+ spawn as manny
processes(ddlhosts) i tell it to - but that's not possible as far as i
know(not with Enterprise Services for sure since i tried). But then if i have
i process for each call i could end up havving to manny of them and time is
lost with the creation of the process and loading all the DDLs and so on...
So i need to control how manny processes i have, somehow.

I hope someone can help me with some simple solution becouse i'v started
already on a C/S solution that uses sockets and it's not as easy as it seamed
:)

I hope i gave you more info now.

"Scott Allen" wrote:
Hi Raul:

STA and MTA are related to COM. Are you saying you have an STA COM
object implemented in C ?

If you have an STA component, you don't need to perform any locking on
an object. COM performs the synchronization for you.

What you might need to do however, is set aspcompat="true" in the
@Page directive. If this component is an STA component it causes the
call to move from an MTA thread running the ASP.NET page into the STA
thread your component has an affinity for.

--
Scott
http://www.OdeToCode.com


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nikhil Barthwal | last post by:
Hi, I have a Java program that needs to access the value of variable PATH (Set in Unix enviroment by setenv or DOS enviroment by PATH statement). How do I access it in Java? Thanks in...
2
by: Steve Juranich | last post by:
If this is a FAQ, please let me know where the answer is. I have in some code an 'eval', which I hate, but it's the shortest path to where I need to get at this point. I thought that one way I...
0
by: Mariano Abdala | last post by:
Hi! My name is Mariaro, I was wondering how to create a fully operational development enviroment for .net web App's?? I would like to know for example, hard you would use, OSs, like Win2003 for...
6
by: Todd | last post by:
Hello, How do I register and non .net dll(with the OS) in a .net enviroment? I have a third party dll I need to register(REGSVR32.EXE). What is the best approach to this in a .Net enviroment. ...
4
by: Benne Smith | last post by:
In our company, i have three servers; 1) a development server (mine only - here i make daily changes and test my stuff) 2) a test server (for the users to test milestone builds - changes weekly)...
5
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
3
by: Ariel | last post by:
hi, Somebody knows some alternative enviroment for visual BASIC .net? thanks.
3
by: pranav123 | last post by:
I want to generate a tree view using c#.net.The tree view should be similar to the Toolbox of the c # developement enviroment has & it should work similarly. Just like in case .net enviroment when...
5
by: kolives | last post by:
Friends i need your help... My lecturer gave me a project o write on encrption and decryption of data (large message body) across a network enviroment. with java using RSA I've been trying some...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.