惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Jina AI
Jina AI
H
Help Net Security
月光博客
月光博客
Y
Y Combinator Blog
I
InfoQ
博客园 - Franky
W
WeLiveSecurity
The Register - Security
The Register - Security
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Blog — PlanetScale
Blog — PlanetScale
H
Hacker News: Front Page
L
LangChain Blog
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
罗磊的独立博客
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
博客园_首页
SecWiki News
SecWiki News
N
News and Events Feed by Topic
B
Blog RSS Feed
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
WordPress大学
WordPress大学
小众软件
小众软件
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Martin Fowler
Martin Fowler
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42
博客园 - 司徒正美
Forbes - Security
Forbes - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
S
Security Affairs

博客园 - Rawu

QT 使用(1) 到广外路线图 假期电话值班问题 test from blogex DB2数据库中提高INSERT性能详解 [zt] Uwyn C++ Coding Standard 成员模板 class template template base -- const coding style Symbian OS C++ for Mobile Phones Volume2 -- hand note [zt]DB2编程小结 写个帖子记录一些小问题。 High-performance SQL Using DB2 routines to ease migration [ICNEWCASTLE]Bad day at the office [ICNEWCASTLE]I'll celebrate! the night before last night 's dream find it for a long time .. PB dddw filter Problem's Solution
Event Sample -- from Professional C#
Rawu · 2007-06-15 · via 博客园 - Rawu

//-- UserRequestEventArgs.cs

using System;

namespace EventSample
{
        
    
public enum RequestType {AdRequest ,PersonalMessageRequest};
    
    
/// <summary>
    
/// Description of UserRequestEventArgs.
    
/// </summary>

    public class UserRequestEventArgs:EventArgs
    
{
        
private RequestType request ;
        
        
public UserRequestEventArgs(RequestType request)
            :
base()
        
{
            
this.request = request;
        }

        
        
public RequestType Request
        
{
            
get 
            
{
                
return request;
            }

        }

    }

}



//-- UserInputMonitor.cs

using System;

namespace EventSample
{        
    
/// <summary>
    
/// Description of UserInputMonitor.
    
/// </summary>

    public class UserInputMonitor
    
{
        
        
public UserInputMonitor()
        
{
            
        }

        
        
public delegate void UserRequest(object sender, UserRequestEventArgs e);
        
        
public event UserRequest OnUserRequest;
        
        
public void Run()
        
{
            
while(true)
            
{
                Console.WriteLine(
"select preferred option ");
                Console.WriteLine(
" request advertisement - hit A then return " );
                Console.WriteLine(
" request personal message from mortimer ---------" + 
                                  
" hit P then return " );
                Console.WriteLine(
" Exit - hit X then return " );
                
                
string response  = Console.ReadLine();
                
                
char responseChar = (response == "")?'-':char.ToUpper(response[0]);
                
                
switch(responseChar)
                
{
                    
case 'A':
                        OnUserRequest(
this,
                                      
new UserRequestEventArgs(RequestType.AdRequest));
                        
break;
                    
case 'P':
                        OnUserRequest(
this,
                                      
new UserRequestEventArgs(RequestType.PersonalMessageRequest));
                        
break;
                    
case 'X':
                        
return ;
                        
                }

                                        
            }

        }

    }

}



//--MessageDisplayer.cs
using System;

namespace EventSample
{
    
/// <summary>
    
/// Description of Class1.
    
/// </summary>

    public class MessageDisplayer
    
{
        
public MessageDisplayer(UserInputMonitor monitor)
        
{
            monitor.OnUserRequest 
+=
                
new UserInputMonitor.UserRequest(UserRequestHandler);
        }

        
        
protected void UserRequestHandler(object sender,UserRequestEventArgs e)
        
{
            
switch(e.Request)
            
{
                
case RequestType.AdRequest:
                    Console.WriteLine(
"Monitor Phone is better than anyone else" + 
                                     
" because \n all our software is written in C#!\n");
                    
break;
                
case RequestType.PersonalMessageRequest:
                    Console.WriteLine(
"Today Monitor issued the following " + 
                                      
"statement: \n Nevermore !\n ");
                    
break;
                    
            }

        }

    }

}



//-- ManagersStaffMonitor.cs 
using System;
using System.Windows.Forms;
namespace EventSample
{
    
/// <summary>
    
/// Description of ManagersStaffMonitor.
    
/// </summary>

    public class ManagersStaffMonitor
    
{
        
public ManagersStaffMonitor(UserInputMonitor monitor)            
        
{
            monitor.OnUserRequest 
+= 
                
new UserInputMonitor.UserRequest(UserRequestHandler);            
        }

        
        
protected void UserRequestHandler(object sender , UserRequestEventArgs e)
        
{
            
if(e.Request == RequestType.PersonalMessageRequest)
            
{
                MessageBox.Show(
"Kaak!","Mortimer says ");
            }

        }

    }

}


//-- Main.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace EventSample
{
    
class MainClass
    
{
        
public static void Main(string[] args)
        
{
            UserInputMonitor inputMonitor 
= new UserInputMonitor();
            MessageDisplayer inputProcessor 
= new MessageDisplayer(inputMonitor);
            ManagersStaffMonitor mortimer 
= new ManagersStaffMonitor(inputMonitor);
            inputMonitor.Run();
        }

    }

}