Results 1 to 3 of 3

Thread: Sleep or delay functioning

  1. #1
    deantop is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2011
    Posts
    2
    Reputation
    0

    Sleep or delay functioning

    I am using a picture box that draws circles (points) in a 2-dimensional plot. Each point is shown on the plot separately through using a "For-Next" statement. In fact, the coordinates x(i),y(i) are calculated and then displayed on the plot by an Ellipse drawing method. In order to provide a realistic sense of drawing, I need to make a delay between tandem drawings of circles. So I used the code system.threading.thread.sleep(1000); however, the whole thread halts and stops drawing and then deliver the plotted graph as a whole at end. Instead of the code, I used a timer; but it didn't work properly, too. I also employed the stopwatch object; it however did not work, too. I also couldn't find a (API) sleep function to add to my program. I have used creating objects , e.g. font object, color object, pen object, etc., and deleting the objects (by Dispose method and set Nothing) after they are not needed to exist at that immediate time. Do you know any solution? Do you know about Windows API Sleep function in VB.Net ? Thank you for your response.

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    13,807
    Reputation
    1705
    The correct option is to use a Timer. If it didn't work when you tried it then you did it wrong. If you show us what you did and tell us what happened then we can probably help you fix it.

    Note that the actual drawing should be done in the Paint event handler of the control you're drawing on. The Timer would be used to force the Paint event to be raised by calling Invalidate on that control.

  3. #3
    deantop is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2011
    Posts
    2
    Reputation
    0
    Thank you very much for your reply. I will check your solution.

    Quote Originally Posted by jmcilhinney View Post
    The correct option is to use a Timer. If it didn't work when you tried it then you did it wrong. If you show us what you did and tell us what happened then we can probably help you fix it.

    Note that the actual drawing should be done in the Paint event handler of the control you're drawing on. The Timer would be used to force the Paint event to be raised by calling Invalidate on that control.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •