CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2016
    Posts
    1

    Sleep or delay functioning in VB.Net

    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
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Sleep or delay functioning in VB.Net

    Sounds like you're putting the sleep into the wrong part of the code, but you'll need to post the code to be sure.

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Sleep or delay functioning in VB.Net

    At a guess I would think that you are doing your drawing on the UI thread and not allowing the UI to update the display.
    You might want to try adding a refresh after each draw and before each sleep.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Sep 2016
    Posts
    8

    Re: Sleep or delay functioning in VB.Net

    Quote Originally Posted by DataMiser View Post
    At a guess I would think that you are doing your drawing on the UI thread and not allowing the UI to update the display.
    You might want to try adding a refresh after each draw and before each sleep.
    is this only in UI case???

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Sleep or delay functioning in VB.Net

    As Arjay mentioned in post #2, it would be helpful if you could post the code used.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Join Date
    Sep 2016
    Posts
    8

    Re: Sleep or delay functioning in VB.Net

    Quote Originally Posted by 2kaud View Post
    As Arjay mentioned in post #2, it would be helpful if you could post the code used.
    fine.. got it

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured