Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


About In-Process and Out-Process

Posted on 2001-07-06
Medium Priority
Last Modified: 2013-11-20

Dear exprets ,

Iam working with ActiveX components in visual basic .
The same i raised in VB section also but not yet got any suggessions.
So i posted the same here.
My problem is ,
Iam calling a In-process (Dll) from a client application.
There is big(coded) method in In -process which is executed by client application having reference of this in-process.
Clearly ,The Client is not going to gain the control unless the entire method get executed.
What i decided to do for this, insted calling this big method , if a client call's another method from that in-process component , which host a out-process component and free the client control as soon as out-process is created .
If that out-process component raise an event of this In-process component after some time Interval. We can execute the big processing method without distrubing the client calling this In-Process component.

Experts Please tell me whether is this is possible.
I tried this and got an error as invalid memory reference after it raise the event from In-Process component
Why this error i got.
Hope experts consider this .

Question by:cpearl_s
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Author Comment

ID: 6259095
Please experts give me reply ASAP
LVL 32

Expert Comment

ID: 6259181
I think you are confusing the concepts of in-process and out-of-process COM and multi-threading.  

I think a better solution to your problem is to have the existing ActiveX control do its long running function in a thread rather than go through the overhead of changing from in-proc to out-of-proc.

Expert Comment

ID: 6259324
jhance is right, changing the location of the server will not alter it's behavior.

Two ways:
a) (as jhance suggested) the client creates a new thread that runs the activex' operation. All Thread Synchronization, Marshaling etc. is  left to the client

b) The ActiveX control creates it's own thread, and offers a function to "start" the operaiton, a functioon to poll the state, and fires an event if the operation is finished.
All threading issues are left to the activeX (I'd prefer this solution for several reasons - but only if you can change the activex)

Note that the Event *must* be fired from the activex control's main thread

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.


Author Comment

ID: 6272814
hai jhance and peter,
Yes , i may confused .

Please reconsider this senario.( Actually this is written in VB but I re-structured using C++  )

My In-process (ActiveX Dll)
Class Order{
    <<--- do long process -->>

Assume this Class is Created and Deployed as
COM+ Application

Client Application --> Creates a Object Order (COM+)
  set obj = CreateObject("ComPls.Order")

If ClientApplication calls this  LongMethod  

Clearly the Client Application won't gain controll back unless and untill that method completes its work.

So , What i thought is, to re-modify the same as.

Modified In-process
implement Class Out
Out ObjOut ;
Class Order{
    <<--- do long process -->>

 Order::StartLongMethod (){
//Create a Out-Process Component
  set ObjOut=CreateObject("OutProcess")

As Soon as this is constructed ,a Timer is Executed to make delay automation. After the timer expires this Raise the LongMethodCallBack .(I mean) as soon as out-process is created the client gains the controll back since this is going to be created in seperate thread.
So i designed my Out-Process Component as
(ActiveX Exe)
Class Out{

 RaiseEvent LongMethodCallBack() ;

 LongMethodCallBack(); // Abstract Method

When the timer event executed , the outprocess timer destroyes and raise the event LongMethodCallBack of In-Process which executes that longfunctionality.
IF i could able to do this , i can acheive two thing,

1) Client Application is not binded with In-Process untill that long method executes .
2) The Out-Process server the Client Application, from binding .

Please consider and tell what i decided is right or wrong else any other way to do this.

Note : The code is only a Overview on the Logic .Just taket he concept only.


Expert Comment

ID: 6272855
a) You don't need an out-of process server for this
In-Process vs. Out-of-Process is only a question of server location, speed and safety. For almost all things legal in COM it doesn't matter if you have a component running inproc or outproc.

b) I'd suggest (simply because I don't know how to do multithreading in VB) to modify the component to use a separate thread for calculation

class Calculator
  HRESULT  StartOperation(); // error if already/still running
  BOOL     IsOperationRunning();
  HRESULT  CancelOperation()

  [outgoing event: operation complete]

StartOperation would create a new thread that calls the lengthy operation.

CancelOperation would best set a flag, that is checkked from time to time in the lengthy op thread. It would then use WaitForSingleObject to wait for the thread to terminate.

When the lengthy operation completes, the thread posts a private Windows message (use RegisterMessage) to the ActiveX control's HWND, and terminates

In the ActiveX controls message handler, you can fire the OperationComplete event.

To take care of:
a) Synchronization beetween the threads
b) the lengthy thread MUST NOT do anything with COM (if it needs, you will need to learn a lot more). not calling COM controls, not firing COM events, etc.


Author Comment

ID: 6288373
hai experts ,
many thanks to u and peter.
Peter i got what u tring to say. But the real problem is Visual basic does not support multithreading model, it support only apartment thread model. There my problem started.
Since iam working with VB. That's what i choosen little bit more effort to solve this problem.
Thought iam still in trouble. I did the same logic using..

A Client Application invokes a Out-Process Component in Client System and that is responsible for executing the COM+ (resides in server) object => Client Application is free from Binging with Server Resources(COm+).After it completes the task ,this againg invoke a Event of Caller (  Client Application )which identifies task completed.

But Actuall i thought , this Out-Process should reside inside the server so that instead of ClientAPplication invokes , let COM+ application (DLL's) invoke the same, which reduce the Client System Overheads.

Any how , though i not completely soveld , i patially solved, this with our experts consulting.
Hope i would get more solution iff i dictate the problem in front of some one.
Wishes to u and experts. Thank's to all


Accepted Solution

peterchen092700 earned 200 total points
ID: 6292948
The whole idea was not to expose the worker thread to COM. The COM threading models alny care about how Interfaces are called from different threads.


Author Comment

ID: 6405202
thank's expert

Expert Comment

ID: 6405241
why only C? What was missing?

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA:…
Suggested Courses

715 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