2

I know this question may be so simple, I have the following code and it should be converted to C#, but the main problem is that I can not understand what below code is doing exactly!!!!...I've searched but I did not find any thing..I Think may be the timeval structure and the select function can be removed with out any consequences!! Am I right?? If no, then How can I convert it to C#??? what is the responsibility of select function exactly?? thanks in advanced.

void WaitMs(UInt32 milliSeconds)
    {
        //start of problem
        struct timeval t=
        { milliSeconds/1000, 
          (milliSeconds%1000)*1000 
        };
        Select(0,NULL,NULL,NULL,&t);
        UInt32 temp=milliSeconds;
     //end of problem
        Logger.NewWait(temp);
    }

I think the code between start of problem and end of problem is not necessary at all! true??

Paridokht
  • 1,374
  • 6
  • 20
  • 45

1 Answers1

2

Time and date values are always transferred by milliseconds value.

For C#:

In C++ there is also a way to do it.

In C#, causing a delay, as Select function does in your code, is made by Thread.Sleep call.

Community
  • 1
  • 1
Ilya Tereschuk
  • 1,204
  • 1
  • 9
  • 21
  • Thanks Elliot, but Could you please tell me what does exactly select function do in the WaitMs function? – Paridokht Dec 29 '13 at 08:47
  • 1
    Usage of this function is [discussed here](http://stackoverflow.com/questions/5198560/using-sleep-and-select-with-signals). Shortly, it is used to **cause a delay** – Ilya Tereschuk Dec 29 '13 at 08:49
  • Is there any function in c# which is equivalent to select in c++ ?? – Paridokht Dec 29 '13 at 09:11