Solved

Automation Object Problem!

Posted on 2001-08-10
8
174 Views
Last Modified: 2013-11-20
Hi,

I've created a simple automation object.
After registering my component, I found I only have the following entries at the registry.

Under My Computer\HKEY_CLASSES_ROOT\CLSID\{ACC29CE5-65E4-11D5-809E-00D0B7273190}

InProcServer
Default -- "c:\test\mytest.dll"

ProgID
Default -- "TestAuto.ExportFun"

But I found other components contain many entires such as

InprocServer32
Default -- "dllpath"
ThreadingModel -- Apartment

And many many other entries I don't have.

How can I create this entry?
What is Apartment indicates?

Thanks!
0
Comment
Question by:ee_lcpaa
  • 3
  • 3
  • 2
8 Comments
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6371840
The first question should be: do you need it? A: depends. For a "simple automation component", it's most of the time "no".

How can I create it?
Add it to the reigstry script

What does it indicate?
the threading model indicates at what level the component may be called from different threads. If the value is not present the component is "unaware of threads", and will get called only from one thread of the container. This is the least work for the component, and mostly the least work for the container, but might degrade performance when


Roughly:

Single Threaded: All Instances are created and called from a single thread
Apartment: components may be created by different threads, but each instance gets called only from the thread that created the component (access to global data must be threadsafe)
Free: any thread can create an instance, and calls can come from any thread (each method must be thread safe)


There are much more issues on that... going beyond the 50pts scope ;)

Helped?
Peter
0
 

Author Comment

by:ee_lcpaa
ID: 6372948
Hi Peterchen,

Do you mean that I can just add the entry to the registry?

ThreadingModel with value = aprament

to allow my automation object to be created from different threads.

No programming will be involved?

Further, for the single threaded mode,
do you mean only one application can use my object at the same time. Another application need to wait the object to be released if the object is being locked!

Is my understanding correct?
0
 

Author Comment

by:ee_lcpaa
ID: 6373019
Hi Peterchen,

Do you mean that I can just add the entry to the registry?

ThreadingModel with value = aprament

to allow my automation object to be created from different threads.

No programming will be involved?

Further, for the single threaded mode,
do you mean only one application can use my object at the same time. Another application need to wait the object to be released if the object is being locked!

Is my understanding correct?
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6374465
Hi,

technically yes, butthere's more to this, I wouldn't do this this without knowing all implications *and* having an actual NEED for this.

1) some Implications

a) different threads can create your object - they will not know that the instance runs in the Main STA, the COM runtime will handle all the marshaling and synchronization for ypu. This is the "slower but safe" approach. slow: we talk about <1ms here. Dispatch interfaces are not the fastest anyway, the additional overhead is typically no problem.

b) The threading model is no "I'd like to", but says what your component is *capable* of. If you declare it apartment threaded, a) YOU must serialize each and every access to global data, and b) the framework you used must do this, too. I assume you wrote the control with MFC - I have no MSDN at hand, I'll check back on monday if there's a way to upgrade your co to "apartment threaded".

2) Reasons why you would mark it apartment threaded

a) Performance in multithreaded clients. Does it make sense for a client to create instances of your component in different threads? (typically, UI components are kept in the main thread for a reason). ONly in this case you need to consider when one of the following confitions is met:
 - the client creates and/or calls instances of your component in/from very many threads,  and calls are highly concurrent
 - you have a method that executes very often in a time critical context (UI and "react on user action" is absolutely *not* critical), and "raw" execution time of this function (i.e. without any marshaling is <10ms.

b) Creation in MTA-Only clients
there are some rare MTA-only clients that require ree threaded components (even i.e. apartment threaded wouldn't be enough). However, these are "exotic special-use", and typically have other high demands on their components; they typically reject "generic" Autoation components anyway.

So, in closing: Don't change anything if you don't really need to. Unless you like a ride on black ice.

Good luck,
Peter

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:ee_lcpaa
ID: 6375115
Hi Peterchen,

In fact, I've downloaded a win32 application form a web site which will perfrom a SNMP operation.

Now, I've created an automation object by MFC and just provide one function to perform the SNMP operation.

This COM will be registerd at the IIS web server and each time my client load my web page, the COM object will be created and perform the SNMP operations. Of course a result will be displayed at the web page.

In my case, I will concern if serveal users load that web page at the same time. Can they use my object concurrently?
Or they will just wait one by one?

I hope they can perform the SNMP operation at the same time. Do you think I need to change me COM object to the apartment threaded?

Thanks for your opinion!
0
 
LVL 7

Accepted Solution

by:
peterchen092700 earned 100 total points
ID: 6376343
1) yes, your scenario cries for at least an apartment model ("Both" = supporting both apartment & free would be useful for scalability, when IIS does pool your helper component. However, supporting freethreaded model often comes close to a complete rewrite)

An Apartment-agnosctic component (like you one currently is) would be a major bottleneck, as IIS processes page requests in separate threads, but the calls to your component are all scheduled to the Main STA thread and processed one after the other

2) Again, I can check MSDN on Monday or tuesday, you could try to locate some information on MFC and Apartments in MSDN, as I have none right here. The biggest question is "Will MFC support this"; I typically write my COM's in ATL, where life seems less awkward ;)

If the server needs to pass lots of pages tgrough your coponent (rule of thumb: is it a dedicated server?), you should also find out if IIS will pool your component, in this case, you should support support both apartment and free threading model (ThreadingModel="Both", but all your methods (ok, your one method) must be thread-safe)

So please have a bit of patience....

Peter

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6911573
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11852798.html
http://www.experts-exchange.com/questions/Q.20033308.html
http://www.experts-exchange.com/questions/Q.20078108.html
http://www.experts-exchange.com/questions/Q.20109495.html
http://www.experts-exchange.com/questions/Q.20112337.html
http://www.experts-exchange.com/questions/Q.20131887.html
http://www.experts-exchange.com/questions/Q.20142790.html
http://www.experts-exchange.com/questions/Q.20162682.html
http://www.experts-exchange.com/questions/Q.20166363.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7079782
Zero response from anyone, finalized.
Moondancer - EE Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now