最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
自定义事件的使用例程
时间:2022-07-02 17:59:58 编辑:袖梨 来源:一聚教程网
自定义事件的使用例程
蓝色力量 [email protected] 转贴请注明:开发者俱乐部(http://www.*de*v*-club.com)
2002.1.22
这段程序运用一个sever类设计一个聊天室:
//此类为服务器类-用于与客户端的通信,其中构造了几个自定义事件
using System;using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace sockchat
{
public delegate void EventServerStartHandler(EventServerStartArgs e); //声明代理
public delegate void EventClientContextHandler(EventClientContextArgs e);
public class EventClientContextArgs //构造自定义事件类
{
public string IP;
public EventClientContextArgs(string _ip)
{
IP = _ip;
}
}
public class EventServerStartArgs :EventArgs
{
public string returnstring;
public EventServerStartArgs()
{
returnstring = "服务器已启动";
}
}
public class server
{
public event EventServerStartHandler SStartEvent;
public event EventClientContextHandler CcontextEvent;
蓝色力量 [email protected] 转贴请注明:开发者俱乐部(http://www.*de*v*-club.com)
2002.1.22
这段程序运用一个sever类设计一个聊天室:
//此类为服务器类-用于与客户端的通信,其中构造了几个自定义事件
using System;using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace sockchat
{
public delegate void EventServerStartHandler(EventServerStartArgs e); //声明代理
public delegate void EventClientContextHandler(EventClientContextArgs e);
public class EventClientContextArgs //构造自定义事件类
{
public string IP;
public EventClientContextArgs(string _ip)
{
IP = _ip;
}
}
public class EventServerStartArgs :EventArgs
{
public string returnstring;
public EventServerStartArgs()
{
returnstring = "服务器已启动";
}
}
public class server
{
public event EventServerStartHandler SStartEvent;
public event EventClientContextHandler CcontextEvent;
相关文章
- 光遇旋转舞者复刻活动怎么玩 09-16
- 原神现在是我的了成就怎么做-现在是我的了成就达成攻略 09-16
- 三国志幻想大陆2枭之歌大医精诚活动如何玩 09-16
- 开放空间宁蒙有什么技能 09-15
- 小鸡舰队出击天空首领活动怎么玩 09-15
- 魔法工艺套装如何解锁使用 09-15