Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have an application that will access interface service A which is to run from windows startup. This service is used by program B and my application functions on B's presence after getting a pointer to A. The scenario is translated as follows,

public interface A{}
///my program
public class MyProgram
{
    public MyProgram()
    {
      ProgramB.DoA();
    }
    public A GetA(){}
}

public class ProgramB
{
   void DoA(){}
}

The translated source is not true, but that seems to be what I am looking for. In order to eliminate the overhead of allocating and realocating dynamic accesses to the same service used by other processes, would you please provide an actual solution to the problem ?(I am all out of any idea now)

share|improve this question
1  
So ProgramB is another process and A is yet another process? How are they communicating with each other? Also, I really don't understand what exactly are you asking. What overhead are you talking about? Are you sure that overhead is actually a problem for you? –  svick Dec 28 '11 at 13:50
    
for stuff like that, I'd consider singleton or better yet, queue –  gnat Dec 28 '11 at 15:00
2  
@gnat would you care to elaborate in an answer instead of a comment how a singleton or a queue would help the OP? Like svick, I'm don't quite understand yet what the question is. –  PersonalNexus Dec 28 '11 at 15:30
    
@PersonalNexus if I had time I'd write an answer instead of comment. But I don't have it now sorry. 1) design queue or singleton to serialize access to service 2) cache as needed to avoid duplicate accesses –  gnat Dec 28 '11 at 16:32
1  
I think @gnat is alluding to a Service Locator pattern with his singleton suggestion. One option I haven't seen mentioned is use of a service architecture, like a web service or WCF server/client. –  neontapir Oct 15 '12 at 21:44
add comment

1 Answer

I don't fathom your intent (and the question title is opaque as well), but if I understand what you are asking WCF supports duplex communication.

http://msdn.microsoft.com/en-us/library/ms731064.aspx

If you are running the service (A) and the client (B) on the same box, you can use a NamedPipe binding which is pretty straightforward. There's a tutorial implementation here that might be helpful:

http://www.switchonthecode.com/tutorials/wcf-tutorial-events-and-callbacks

If I've misunderstood your question, please disregard.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.