[收藏]IOCP Thread Pooling in C#[28]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 zhengyun_ustc 的 blog

     

      pthreadpool.postevent(10);

     

      thread.sleep(100);

     

      pthreadpool.dispose();

    }

   

    //********************************************************************

    /// <summary> function to be called by the iocp thread pool.  called when

    ///           a command is posted for processing by the socketmanager </summary>

    /// <param name="ivalue"> the value provided by the thread posting the event </param>

    static public void iocpthreadfunction(int32 ivalue)

    {

      try

      {

        console.writeline("value: {0}", ivalue);

      }

     

      catch (exception pexception)

      {

        console.writeline(pexception.message);

      }

    }

  }

}

 

this is what you should see when you run the sample application.  on your own change the main function to call the postevent method several times and see how the iocp thread pool performs.

 

 

review

this class provides the iocp thread pooling support your server based software requires.  by using this class, you can build efficient and robust servers that can scale as the amount of work increases.  though there are some limitations due to the nature of the managed heap and unsafe code, these limitations can easily be overcome with a little ingenuity.

 

本文关键:[收藏]IOCP Thread Pooling in C#
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top