Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. CAlling callbacks from outside service handler

CAlling callbacks from outside service handler

Scheduled Pinned Locked Moved WCF and WF
questioncsharpdatabasewcfcom
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dewald
    wrote on last edited by
    #1

    OK, so I'm slowly making progress with WCF. I have a question on callbacks and where they can be called from. I've found this awesome article which, almost exactly, addresses what I'm trying to achieve. The hosting application has the following block of code:

    using (ServiceHost host = new ServiceHost(typeof(BeerService)))
    {
    host.Open();

    Console.WriteLine("Service is ready for requests.  Press any key to close service.");
    Console.WriteLine();
    
    Console.Read();
    
    Console.WriteLine("Closing service...");
    

    }

    Inside BeerService is where the magic happens. I'd like to trigger some of that magic from inside the server side application, the code block above, but how do I do that? I don't have access to an instance of BeerService, all I have is access to host which is an instance of ServiceHost, not BeerService. Essentially, this is what I'd like to be able to do, but can't:

    using (ServiceHost host = new ServiceHost(typeof(BeerService)))
    {
    host.Open();

    Console.WriteLine("Service is ready for requests.  Press any key to close service.");
    Console.WriteLine();
    
    int c;
    do
    {
        c = Console.Read();
        if (c == 'b')
            // Here is the line that I'd like to be able to call but can't because MakeBeerRun() is a member of BeerService and I don't have access to an instance of it
            host.MakeBeerRun("The Party Owner", 12);
    } while (c == 'b');
    
    Console.WriteLine("Closing service...");
    

    }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups