RemoteObject.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:1k
- using System;
- namespace Wrox.ProCSharp.Remoting
- {
- [Serializable]
- public class StatusEventArgs
- {
- public StatusEventArgs(string m)
- {
- message = m;
- }
- public string Message
- {
- get
- {
- return message;
- }
- set
- {
- message = value;
- }
- }
- private string message;
- }
- public delegate void StatusEvent(object sender, StatusEventArgs e);
- public class RemoteObject : System.MarshalByRefObject
- {
- public RemoteObject()
- {
- Console.WriteLine("RemoteObject Constructor called");
- }
- public event StatusEvent Status;
- public void LongWorking(int ms)
- {
- Console.WriteLine("RemoteObject: LongWorking() Started");
- StatusEventArgs e = new StatusEventArgs(
- "Message for Client: LongWorking() Started");
- // fire event
- if (Status != null)
- {
- Console.WriteLine("RemoteObject: Firing Starting Event");
- Status(this, e);
- }
- System.Threading.Thread.Sleep(ms);
- e.Message = "Message for Client: LongWorking() Ending";
- // fire ending event
- if (Status != null)
- {
- Console.WriteLine("RemoteObject: Firing Ending Event");
- Status(this, e);
- }
- Console.WriteLine("RemoteObject: LongWorking() Ending");
- }
- }
- }