Re: Nonblocking read from System.Console

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 04/22/04


Date: Thu, 22 Apr 2004 13:37:07 -0400

gotcha. Here is what I would probably do. What you really want is a server
and management client. The server will surface a management api as services
like dns, exchange, and others do. That way you mgmt client can be
anything, web client, console client, win client. Your service just runs in
its loop doing its thing. The easiest way is probably surface some Remoting
APIs. Remoting is good for you because your not sharing the management of
the server across the world, but just your management app - so having them
tight would seem good for this.
1) Your server surfaces a few management APIs like DoCommand(command)
2) The DoCommand method will take a string or a command object that you
define.
3) This method will interact with your shared data structors in the server
(need to sync them carefully as normal)
4) So to kick a user (for example) it will lock the users collection and
remove that user and then unlock it. The server thread will lock shared
objects before using them.
5) The method (in this example) could just return a bool that it was
successful or not to your remoting client.
6) You may also have a ListPlayers() remoted method that returns a string[].
7) Your client then just displays the results.

So your server just runs as a service and does its thing in a loop. You can
have one or more management clients that do commands agaist it using
remoting. The client runs as a seperate app in its own process. They can
talk to each other with remoting. Does that help?

-- 
William Stacey, MVP
"Tobias Mattsson" <sigget at europe dot com> wrote in message
news:OaYdJ4GKEHA.2624@TK2MSFTNGP09.phx.gbl...
> They're one line commands such as: listplayers, kick <name>, quit, and so
> on.
>
> "William Stacey [MVP]" <staceywREMOVE@mvps.org> wrote in message
> news:%23yieNOCKEHA.556@TK2MSFTNGP10.phx.gbl...
> > What will you do with the console input?  Are they commands to the
network
> > service (i.e. start, stop, etc) or data that the service sends out?  I
ask
> > to help formulate a better reply.
> >
> > -- 
> > William Stacey, MVP
> >
> > "Tobias Mattsson" <sigget at europe dot com> wrote in message
> > news:OVyvca$JEHA.624@TK2MSFTNGP11.phx.gbl...
> > > I have a console application that continously serves a set of network
> > > connections, now i want to add a command prompt. So what i need is to
> poll
> > > for pending input from System.Console in that loop and assemble lines
to
> > > interpret. Ive tried using OpenStandardInput to get a Stream object,
but
> > > there is no way to find out how much data is pending on such  a
stream.
> > And
> > > it doesnt support asyncronous operations through BeginRead. So im
> looking
> > at
> > > using async delegates, but as ive understood it they create a worker
> > thread,
> > > and since i need a call for each character that becomes a lot of
> overhead.
> > I
> > > could of course just throw console.readline in a thread of its own,
but
> > then
> > > i get problems shutting that thread down. I need to get a waithandle
> from
> > > somewhere and use that in a seperate thread or poll it in the main
loop.
> > >
> > > In Win32 id use GetStdHandle() to get a HANDLE and then
> > WaitForSingleObject
> > > to poll it, how can i do this in .NET ?
> > >
> > >
> >
>
>


Relevant Pages

  • Re: Package Cannot Be Located
    ... Proxy Management Point and that the System Management container in AD has the ... new entry and that the entry for the old server is no longer there. ... I'd then install a new client and check that it picked up the new MP data. ... package content or advertised programs from a Distribution Point. ...
    (microsoft.public.sms.misc)
  • Re: Package Cannot Be Located
    ... There was any entry in the System Management ... container for the old server. ... "Bernie Kilshaw" wrote: ... I'd then install a new client and check that it picked up the new MP data. ...
    (microsoft.public.sms.misc)
  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)
  • This is going straight to the pool room
    ... or not the client has privilege to do what they're trying to do, ... The server environment is this: ... 3GL User action Routines that Tier3 will execute on your behalf during the ... Routine Name: USER_INIT ...
    (comp.os.vms)
  • [Full-Disclosure] R: Full-Disclosure Digest, Vol 3, Issue 42
    ... Full-Disclosure Digest, Vol 3, Issue 42 ... SD Server 4.0.70 Directory Traversal Bug ... Arkeia Network Backup Client Remote Access ...
    (Full-Disclosure)