RSS
热门关键字:
当前位置 :| 主页>net development>

The observer mode in Asp.net

来源: 作者:Stand originally 时间:2008-12-21 Tag: 点击:

Does observer mode come true in ASP.net? what does the observer mode in ASP.NET have special? Hum, the Application hard to avoid that is based on Http agreement is a little forgetful, I am such implementation, do not know to have better idea?

Talk about demand first, lest be immersed in theoretic

Recently a Case, such demand: End of a lot of clients is ceaseless submit data to Web Application, the administrator enters the administrative page of Web to be able to see these data immediately, many administrators can be browsed at the same time, and the data that the administrator scans begins to monitor that hour rises from the administrator, cannot show the data previously. Look from this setting, clear observer pattern, when the administrator begins to monitor, subscription data, when data arrives to all subscription the administrator broadcast data of data.

Demand pursues as follows:

Had the person that promulgator still needs subscription, we realize an administrator kind, will subscribe to data

Public Class Admin
{
/ **//// <summary>
/ / / the data that saves all receiving with this
/ / / </summary>Public IList<string>MessageList
{Get; Set; }Public Admin(Monitor Monitor)
{
MessageList = New List<string>();Monitor.DataIn = New EventHandler<DataEventArgs>(ReciveMessage);
}

Private Void ReciveMessage(object Sender, dataEventArgs E)


{

MessageList.Add(e.Message);

}

}

Ok, we had written the element that need has, but how to let their job rise? If make Winform program, that will be without be concerned about.

Analysis: The problem that we encounter

The first problem: When the client end sends package of a data, are we example changes a new Monitor? If be, which every time example changes a brand-new Monitor, all is in above it the incident of subscription will disappear entirely, how will if be this Monitor,exist? Always cannot vacuum, how is data saved between two Http request? Read demand again nevertheless, in be like whole application process, need to also can have a such Monitor only only, should be odd when mode enters the court.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册