|
/* (C) 2005 by Frank McCown
* You may modify or use this code in any way you would like.
*/
using System;
using System.Threading;
namespace guiexample
{
public class Greeter : MarshalByRefObject
{
// Used by GUI to listen for SayHello calls
public delegate void HelloEventHandler(object sender, HelloEventArgs e);
public event HelloEventHandler HelloEvent;
// Time in msec to wait until we respond to the Client
private int mRespondTime;
public int RespondTime
{
get { return mRespondTime; }
set { mRespondTime = Math.Max(0, value); }
}
public Greeter()
{
// Default no argument constructor
}
public override Object InitializeLifetimeService()
{
// Allow this object to live "forever"
return null;
}
public String SayHello(String name)
{
// Inform the GUI that SayHello was called
HelloEvent(this, new HelloEventArgs(name));
// Pretend we're computing something that takes a while
Thread.Sleep(mRespondTime);
return "Hello there, " + name + "!";
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Frank McCown is an assistant professor of Computer Science at Harding University (Searcy, Arkansas, USA). His research interests include web crawling, search engines, digital preservation, and web archiving.