• C#委托实现系统回调


    在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);
            }

  • 相关阅读:
    Centos7 yum 安装 oracle-rdbms-server-11gR2-pre
    R语言 小程序
    Hadoop! | 大数据百科 | 数据观 | 中国大数据产业观察_大数据门户
    【R】如何确定最适合数据集的机器学习算法
    R语言 recommenderlab 包
    R语言 推荐算法 recommenderlab包
    R语言进行数据预处理wranging
    统计学 nested_design 嵌套设计
    [LeetCode] 160. 相交链表
    [LeetCode] 155. 最小栈
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/1299655.html
Copyright © 2020-2023  润新知