Sorry about that posting MC++ code insted fo c# code. But i was only
pointing the functionality of System.threading.thread.sleep(mill sec)
or  sleep(TImeSpan(int64 ticks)) .

I can give sudo code in c#
-------------------------------------------

void SendData(array bigchunkdata)
{

  int smallchunksize = 64;
  byte[] smallchunkdata = new array(smallchunksize) ;

 for( int i =0; i<= bigchunkdata.length; i=i+smallchunksize)
{

        System.Array.Copy(bigchunkdata,i,smallchunkdata ,
0,smallchunksize);
        MyScoketObj.Send(smallchunkdata );

        if(Osversion >=6)
          System.threading.thread.currentthread.sleep(8);   // this
sleeping works on vista OS   i.e Osverssion.major >=6
        else
           waite8mills();
}

void waite8mills()
{
     StopWath mystopwatch = StopWatch.createnew();

     while(mystopwatch->elapsedtime <8)
         {

                 // DO nothing        // this bit causing CPU usage
any function to make not to use CPU appriciated  Sleep(1 to 15)
returning after minuimum 15 mils because of minimum tick time in OS is
15 mills
        }
}

//other way of implimenting waite8mills

void waite8mills()
{
    LARGE_INTEGER ticksPerSecond;
     LARGE_INTEGER tick;

     long one_ms =0;
     long  wait_until =0;

     QueryPerformanceFrequency(ref ticksPerSecond );

       one_ms = ticksPerSecond.QuadPart/1000;

       QueryPerformanceCounter( ref tick);

       wait_until = (8*one_ms) + tick.QuadPart;

  while (tick.QuadPart < one_until )
  {
          CurrentThread.Sleep(System::TimeSpan(8*one_ms));
          QueryPerformanceCounter(ref tick);
  }
}

In both ways fo waiting causing eaither 15 mills of delay on sleep or
100% CPU usage .


Any suggestinons for wating accurate time or sleeping accurate time
wiath out causing CPU usage.


Thanks



Reply via email to