Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Drawing in loop

Drawing in loop

Scheduled Pinned Locked Moved C#
helpquestiongraphicsgame-dev
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nikhil Wason
    wrote on last edited by
    #1

    friends i m having problem in displaying the form in a loop: do { this.boardRenderer.DisplayBoard(gameBoard); }while() the DisplayBoard function draws on the form but when it is called in from a loop, the main form is not displayed until the processing of the loop is over (END OF GAME IN MY CASE :'( ) how can i make it display the form while processing other code?? PLZZZZ HELP!!

    L J 3 Replies Last reply
    0
    • N Nikhil Wason

      friends i m having problem in displaying the form in a loop: do { this.boardRenderer.DisplayBoard(gameBoard); }while() the DisplayBoard function draws on the form but when it is called in from a loop, the main form is not displayed until the processing of the loop is over (END OF GAME IN MY CASE :'( ) how can i make it display the form while processing other code?? PLZZZZ HELP!!

      L Offline
      L Offline
      Le centriste
      wrote on last edited by
      #2

      That is normal, the repaint happens in the same thread. You will need to have a worker thread that draws on the form using delegates. I am sure there is a tutorial here on code project. -------- "I say no to drugs, but they don't listen." - Marilyn Manson -- modified at 16:05 Monday 5th June, 2006

      N 1 Reply Last reply
      0
      • N Nikhil Wason

        friends i m having problem in displaying the form in a loop: do { this.boardRenderer.DisplayBoard(gameBoard); }while() the DisplayBoard function draws on the form but when it is called in from a loop, the main form is not displayed until the processing of the loop is over (END OF GAME IN MY CASE :'( ) how can i make it display the form while processing other code?? PLZZZZ HELP!!

        L Offline
        L Offline
        Le centriste
        wrote on last edited by
        #3

        A link to a very good article on the subject: [^] Read thoroughly!!! :mad: -------- "I say no to drugs, but they don't listen." - Marilyn Manson

        N S 2 Replies Last reply
        0
        • L Le centriste

          That is normal, the repaint happens in the same thread. You will need to have a worker thread that draws on the form using delegates. I am sure there is a tutorial here on code project. -------- "I say no to drugs, but they don't listen." - Marilyn Manson -- modified at 16:05 Monday 5th June, 2006

          N Offline
          N Offline
          Nikhil Wason
          wrote on last edited by
          #4

          Thanx michel but the thing is i only want to draw the board whenever the player makes a move not randomly so will worker thread be usefull then also? regards

          D 1 Reply Last reply
          0
          • L Le centriste

            A link to a very good article on the subject: [^] Read thoroughly!!! :mad: -------- "I say no to drugs, but they don't listen." - Marilyn Manson

            N Offline
            N Offline
            Nikhil Wason
            wrote on last edited by
            #5

            HEY THNX BUDDY.. U ROCK :)

            1 Reply Last reply
            0
            • N Nikhil Wason

              Thanx michel but the thing is i only want to draw the board whenever the player makes a move not randomly so will worker thread be usefull then also? regards

              D Offline
              D Offline
              Dan Neely
              wrote on last edited by
              #6

              Yes

              1 Reply Last reply
              0
              • N Nikhil Wason

                friends i m having problem in displaying the form in a loop: do { this.boardRenderer.DisplayBoard(gameBoard); }while() the DisplayBoard function draws on the form but when it is called in from a loop, the main form is not displayed until the processing of the loop is over (END OF GAME IN MY CASE :'( ) how can i make it display the form while processing other code?? PLZZZZ HELP!!

                J Offline
                J Offline
                Josh Smith
                wrote on last edited by
                #7

                If the game board really needs to be updated a zillion times a second, then you might want to consider triggering the rendering logic via a Timer. If the frequency of invalidation is not that common, then you might just want to handle the Paint event of a Panel and render the game board there. Josh

                1 Reply Last reply
                0
                • L Le centriste

                  A link to a very good article on the subject: [^] Read thoroughly!!! :mad: -------- "I say no to drugs, but they don't listen." - Marilyn Manson

                  S Offline
                  S Offline
                  S Senthil Kumar
                  wrote on last edited by
                  #8

                  Thanks for the plug ;)

                  Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups