在C#中,系统回调感觉都是用委托实现的(实际委托就应该称为OO化的函数回调)
比较典型的是三个
1.cache
CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove);
HttpContext.Current.Cache.Insert(CacheKey, CacheInfo, null,
System.DateTime.Now.AddSeconds(300),
System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Default,
callBack);
/// <summary>
/// cache失效时触发
/// </summary>
/// <param name="IdentifyCode"></param>
/// <param name="Info"></param>
/// <param name="reason"></param>
private static void onRemove(string IdentifyCode, object CacheInfo, CacheItemRemovedReason reason)
{
}
2.Timer
System.Timers.Timer SSOTimer = new System.Timers.Timer(10000);
SSOTimer.Elapsed += new System.Timers.ElapsedEventHandler(SSOTimer_Elapsed);
SSOTimer.AutoReset = true;
SSOTimer.Enabled = true;
/// <summary>
/// 达到间隔时发生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SSOTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
}
3.异步传输
AsyncCallback acb = new AsyncCallback(WebCallback);
IAsyncResult IAR = BeginByte(WholeParameters, acb, null);
Byte[] ReturnValue = EndByte(IAR);
/// <summary>
/// 数据传输完成调用此方法
/// </summary>
/// <param name="IAR"></param>
protected void WebCallback(IAsyncResult IAR)
{
//Byte[] ReturnValue = EndPublicObjectHashtableByte(IAR);
}