Archived

This forum has been archived. Please start a new discussion on GitHub.

waitForShutdown method

Hi

I'm using the Client / Server 'Hello World' example in C# given in your documentation, but there appears to be a problem.

On the server side, after the client message has been received the Ice Communicator doesn't shut down.

i.e. in this section of the code

adapter.activate();
ic.waitForShutdown();
Console.WriteLine("My message");

The writeline never appears, even after a message is received from the client. The Ice Communicator is never destroyed because the code never gets that far... I know there are other methods (.destroy(), .shutdown(), etc) that I can use to kill the server. But I want to wait for a message to be received first.

Is it possible to open the server and wait until a message is received, then close the server and continue? So I am able to do something, open a server, wait until a message is received and then continue my program.

thanks

Comments

  • bernard
    bernard Jupiter, FL
    Hi Sion,

    ic.waitForShutdown() will return when the communicator is shut down. Do you call shutdown on the communicator anywhere in your code?

    You could for example shut down the communicator as part of the implementation of a remote operation.

    Best regards,
    Bernard
  • Is there a better way for me to get a server to wait for a reply before proceeding?

    Alternatively, how would I cause the server to shutdown remotely? In the example the Ice Communicator (variable name ic) is created locally, so how would I destroy it remotely?

    thanks
  • Don't worry, I've worked it out. Thanks anyway.