c# - Can I define frequency check for ThreadPool.QueueUserWorkItem? -


I limit the bandwidth usage of websites to download files to System.Web.IHttpAsyncHandler Implemented. After defined user bandwidth, I need to send a byte [] every second (or 1000 milliseconds, to be exact) Something like this:

  Public class DownloadHandler: IHttpAsyncHandler {Public IAsyncResult StartProcessRequest (HttpContext Reference, AsyncCallback CB, Object Additional Data) {// Users can download that file? DownloadAsync Download = New DownloadAsync (...); download. Start Download () Return Download; }} Category DownloadAync: IAsyncResult {// ... Public Zero Start Download () {ThreadPool.QueueUserWorkItem (New WaitCallback (startAsyncTask)); } Private Zero StartSync Task (object state) {// ... while (References. ISLLT connect and offset & amp; lt; data. Arivio.Tomano) {// ... reference of dots. Response. Write buffer, 0, readcount); // ... more stuff threads Sleep (1000 - (insured) insured insured balance); }  

Once the ThreadPull.QUUAderWorker item , I lose control over the frequency my code is being executed, so it does not take another to execute , And this difference reflects on the download throughput.

So, my questions are:

  1. Can I define ThreadPool.QueueUserWorkItem check interval?
  2. If not, then is there another approach to achieving this requirement? (Bandwidth throttling?)
  3. If not, can I have a pony?

TIA

You do not hang on a poolside like this should do. And in general, there is a doubt about any threading solution that uses sleep ().

You can use, I'm not sure about the accuracy (about ~ 20 MMS), but it will not be 'wandering'.

The timer will change the loop inside your representative.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -