Can someone help me with this... 
Author Message
 Can someone help me with this...

I created an ATL Local server using the Wizard in VC++.  Then I created a
simple object for it.
From another application (written in MFC) I am calling CoCreatInstance to
get an interface to this object.  Then I call one of the interfaces methods.
This starts the local server and this works fine.  The problem is this:

The method that is called takes a LONG TIME to finish.  This causes the
application that called CoCreateInstance to hang.

I don't understand why this hapens.  The code that takes a long time is part
of the local server and should be running in a seperate thread correct?  Or
does it run in the same thread that created the interface?

Does anyone know how I can solve this problem.

Thanks,
Pete



Fri, 25 Feb 2005 12:36:34 GMT  
 Can someone help me with this...
The method runs in the local server, necessarily in a different thread
and even in a different process. But the calling thread is suspended
until the server returns. Think about it -if the call returns
immediately without waiting for the server to finish, how would you
obtain the return value and any [out] parameters?

You can pass a callback interface, implemented by client, to the
long-running method. The server will then initiate processing of the
request (say, on a secondary thread) and return immediately. When the
request is processed, the server calls back on the client-supplied
interface to report results. Or, you can fire an event via connection
point mechanism.

Win2K and above support asynchronous COM calls natively. See
"Non-Blocking Method Calls" at

http://msdn.microsoft.com/library/en-us/dncomg/html/nbmc.asp

--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I created an ATL Local server using the Wizard in VC++.  Then I
created a
> simple object for it.
> From another application (written in MFC) I am calling CoCreatInstance
to
> get an interface to this object.  Then I call one of the interfaces
methods.
> This starts the local server and this works fine.  The problem is
this:

> The method that is called takes a LONG TIME to finish.  This causes
the
> application that called CoCreateInstance to hang.

> I don't understand why this hapens.  The code that takes a long time
is part
> of the local server and should be running in a seperate thread
correct?  Or
> does it run in the same thread that created the interface?

> Does anyone know how I can solve this problem.

> Thanks,
> Pete



Sat, 26 Feb 2005 00:14:59 GMT  
 Can someone help me with this...
Thanks you for your help.  I solved the problem by creating another thread
from the client and the thread starts the server.  But now I have another
problem.  I think I would still have this problem if I used your methods.
Here is the problem.

Since the server method that is called takes a LONG TIME to finish, if the
user quits the client application the server gets screwed up and doesn't do
what it's supposed to do.  I want the server to finish what it's doing even
if the client thread that started the server quits before the server
finishes.  I don't care if I get back a result from the server.  It appears
that the server is screwing up because the client thread that started it has
gone away - via closing the client application.

Any ideas?

Thanks,
Pete


necessarily in a different thread

Quote:
> and even in a different process. But the calling thread is suspended
> until the server returns. Think about it -if the call returns
> immediately without waiting for the server to finish, how would you
> obtain the return value and any [out] parameters?

> You can pass a callback interface, implemented by client, to the
> long-running method. The server will then initiate processing of the
> request (say, on a secondary thread) and return immediately. When the
> request is processed, the server calls back on the client-supplied
> interface to report results. Or, you can fire an event via connection
> point mechanism.

> Win2K and above support asynchronous COM calls natively. See
> "Non-Blocking Method Calls" at

> http://msdn.microsoft.com/library/en-us/dncomg/html/nbmc.asp

> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > I created an ATL Local server using the Wizard in VC++.  Then I
> created a
> > simple object for it.
> > From another application (written in MFC) I am calling CoCreatInstance
> to
> > get an interface to this object.  Then I call one of the interfaces
> methods.
> > This starts the local server and this works fine.  The problem is
> this:

> > The method that is called takes a LONG TIME to finish.  This causes
> the
> > application that called CoCreateInstance to hang.

> > I don't understand why this hapens.  The code that takes a long time
> is part
> > of the local server and should be running in a seperate thread
> correct?  Or
> > does it run in the same thread that created the interface?

> > Does anyone know how I can solve this problem.

> > Thanks,
> > Pete



Sat, 26 Feb 2005 11:53:45 GMT  
 Can someone help me with this...
Define "screwed". Exactly what's going wrong?
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Thanks you for your help.  I solved the problem by creating another
thread
> from the client and the thread starts the server.  But now I have
another
> problem.  I think I would still have this problem if I used your
methods.
> Here is the problem.

> Since the server method that is called takes a LONG TIME to finish, if
the
> user quits the client application the server gets screwed up and
doesn't do
> what it's supposed to do.  I want the server to finish what it's doing
even
> if the client thread that started the server quits before the server
> finishes.  I don't care if I get back a result from the server.  It
appears
> that the server is screwing up because the client thread that started
it has
> gone away - via closing the client application.

> Any ideas?

> Thanks,
> Pete



server,
> necessarily in a different thread
> > and even in a different process. But the calling thread is suspended
> > until the server returns. Think about it -if the call returns
> > immediately without waiting for the server to finish, how would you
> > obtain the return value and any [out] parameters?

> > You can pass a callback interface, implemented by client, to the
> > long-running method. The server will then initiate processing of the
> > request (say, on a secondary thread) and return immediately. When
the
> > request is processed, the server calls back on the client-supplied
> > interface to report results. Or, you can fire an event via
connection
> > point mechanism.

> > Win2K and above support asynchronous COM calls natively. See
> > "Non-Blocking Method Calls" at

> > http://msdn.microsoft.com/library/en-us/dncomg/html/nbmc.asp

> > --
> > With best wishes,
> >     Igor Tandetnik

> > "For every complex problem, there is a solution that is simple,
neat,
> > and wrong." H.L. Mencken



> > > I created an ATL Local server using the Wizard in VC++.  Then I
> > created a
> > > simple object for it.
> > > From another application (written in MFC) I am calling
CoCreatInstance
> > to
> > > get an interface to this object.  Then I call one of the
interfaces
> > methods.
> > > This starts the local server and this works fine.  The problem is
> > this:

> > > The method that is called takes a LONG TIME to finish.  This
causes
> > the
> > > application that called CoCreateInstance to hang.

> > > I don't understand why this hapens.  The code that takes a long
time
> > is part
> > > of the local server and should be running in a seperate thread
> > correct?  Or
> > > does it run in the same thread that created the interface?

> > > Does anyone know how I can solve this problem.

> > > Thanks,
> > > Pete



Sat, 26 Feb 2005 21:37:19 GMT  
 Can someone help me with this...
It;s not finishing the job it was supposed to do.  And the server just hangs
there.


Quote:
> Define "screwed". Exactly what's going wrong?
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Thanks you for your help.  I solved the problem by creating another
> thread
> > from the client and the thread starts the server.  But now I have
> another
> > problem.  I think I would still have this problem if I used your
> methods.
> > Here is the problem.

> > Since the server method that is called takes a LONG TIME to finish, if
> the
> > user quits the client application the server gets screwed up and
> doesn't do
> > what it's supposed to do.  I want the server to finish what it's doing
> even
> > if the client thread that started the server quits before the server
> > finishes.  I don't care if I get back a result from the server.  It
> appears
> > that the server is screwing up because the client thread that started
> it has
> > gone away - via closing the client application.

> > Any ideas?

> > Thanks,
> > Pete



> server,
> > necessarily in a different thread
> > > and even in a different process. But the calling thread is suspended
> > > until the server returns. Think about it -if the call returns
> > > immediately without waiting for the server to finish, how would you
> > > obtain the return value and any [out] parameters?

> > > You can pass a callback interface, implemented by client, to the
> > > long-running method. The server will then initiate processing of the
> > > request (say, on a secondary thread) and return immediately. When
> the
> > > request is processed, the server calls back on the client-supplied
> > > interface to report results. Or, you can fire an event via
> connection
> > > point mechanism.

> > > Win2K and above support asynchronous COM calls natively. See
> > > "Non-Blocking Method Calls" at

> > > http://msdn.microsoft.com/library/en-us/dncomg/html/nbmc.asp

> > > --
> > > With best wishes,
> > >     Igor Tandetnik

> > > "For every complex problem, there is a solution that is simple,
> neat,
> > > and wrong." H.L. Mencken



> > > > I created an ATL Local server using the Wizard in VC++.  Then I
> > > created a
> > > > simple object for it.
> > > > From another application (written in MFC) I am calling
> CoCreatInstance
> > > to
> > > > get an interface to this object.  Then I call one of the
> interfaces
> > > methods.
> > > > This starts the local server and this works fine.  The problem is
> > > this:

> > > > The method that is called takes a LONG TIME to finish.  This
> causes
> > > the
> > > > application that called CoCreateInstance to hang.

> > > > I don't understand why this hapens.  The code that takes a long
> time
> > > is part
> > > > of the local server and should be running in a seperate thread
> > > correct?  Or
> > > > does it run in the same thread that created the interface?

> > > > Does anyone know how I can solve this problem.

> > > > Thanks,
> > > > Pete



Tue, 01 Mar 2005 11:46:43 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help with compiling a "canned" program

2. SOMEONE HELP ME, HELP ME, HELP ME PLEASE...

3. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

4. HELP: Could someone help me out with this?

5. Determining what canned preprocessor symbols are available

6. Beginner [Q] Using Canned File Open/Save dialog

7. Canned Dialogs

8. help finding someone

9. Can someone help me w/ this program...

10. Can someone help me with the following Exercise

11. Can someone please help me locate the logic error

12. Can someone help me to port this short qbasic code to C (linux C)

 

 
Powered by phpBB® Forum Software