Drawing in loop
-
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!!
-
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!!
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
-
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!!
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
-
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
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
-
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
HEY THNX BUDDY.. U ROCK :)
-
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
-
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!!
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
-
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
Thanks for the plug ;)
Regards Senthil _____________________________ My Blog | My Articles | WinMacro