creating a delay

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ChrisB

    #1

    creating a delay

    Hello:

    I was wondering if someone might have a recommendation for creating a delay
    within the execution of a .dll.

    Currently I am using an empty for/next loop and it takes about 1 billion
    cycles seems to create a 1 second delay (I know, probably not a good idea).

    I was considering thread.sleep() but don't want to create any unintentional
    side effects. Would this be a good idea or are there better options?

    Thanks!

    Chris


  • Vijaye Raji

    #2
    Re: creating a delay

    What other side effects do you think it might create?

    Sleep is the recommended method of delay. Looping forever will choke the
    CPU and starve other lower priority threads.

    If you are waiting for something, use Synchronization .

    -vJ

    "ChrisB" <pleasereplytog roup@thanks.com > wrote in message
    news:OiUuQnSuDH A.1060@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hello:
    >
    > I was wondering if someone might have a recommendation for creating a[/color]
    delay[color=blue]
    > within the execution of a .dll.
    >
    > Currently I am using an empty for/next loop and it takes about 1 billion
    > cycles seems to create a 1 second delay (I know, probably not a good[/color]
    idea).[color=blue]
    >
    > I was considering thread.sleep() but don't want to create any[/color]
    unintentional[color=blue]
    > side effects. Would this be a good idea or are there better options?
    >
    > Thanks!
    >
    > Chris
    >
    >[/color]


    Comment

    • Frank Oquendo

      #3
      Re: creating a delay

      ChrisB wrote:[color=blue]
      > Hello:
      >
      > I was wondering if someone might have a recommendation for creating a
      > delay within the execution of a .dll.[/color]

      What's the delay for?
      [color=blue]
      > I was considering thread.sleep() but don't want to create any
      > unintentional side effects. Would this be a good idea or are there
      > better options?[/color]

      Unless you're modifying data within the thread, I don't see a problem.

      --
      There are 10 kinds of people. Those who understand binary and those who
      don't.


      (Pull the pin to reply)


      Comment

      • Greg Beech [MSFT]

        #4
        RE: creating a delay

        Thread.Sleep() is great for this sort of thing - it's exactly what it is
        designed for.

        Greg

        This posting is provided "AS IS"with no warranties, and confers no rights.

        Comment

        • ChrisB

          #5
          Re: creating a delay

          Thanks to everyone for the advice.

          I am creating the delay for a test component so that information is written
          to a database at specified intervals - sounds like thread.sleep() is the way
          to go.

          I'll give it a try . . .

          Chris

          "Greg Beech [MSFT]" <gregbee@online .microsoft.com> wrote in message
          news:LWF15CTuDH A.1360@cpmsftng xa06.phx.gbl...[color=blue]
          > Thread.Sleep() is great for this sort of thing - it's exactly what it is
          > designed for.
          >
          > Greg
          >
          > This posting is provided "AS IS"with no warranties, and confers no rights.
          >[/color]


          Comment

          Working...