Trying to multithread program. C++/CLI - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Trying to multithread program. C++/CLI

  1. #16
    Join Date
    Apr 2013
    Posts
    9

    Re: Trying to multithread program. C++/CLI

    yea i've never heard of a .net 4.3 either actually but i figured i'd take his word for it. I'll try and inclue the .NET framework installation with my setup program will be easier than making people install it manually. i'll also include the 2012 redistributables.

    So you think i should use a Timer and on every timer tick draw everything whilst continuously doing the calculations required??
    Or do you mean Update and Draw on one timer tick but use the stopclock just to keep track of the time taken to put into my calculations??

  2. #17
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,591

    Re: Trying to multithread program. C++/CLI

    Quote Originally Posted by welsh4evr View Post
    So you think i should use a Timer and on every timer tick draw everything whilst continuously doing the calculations required??
    I'm not quite sure what you mean by "continuously", but if that involves a loop, then definitely no.

    Or do you mean Update and Draw on one timer tick but use the stopclock just to keep track of the time taken to put into my calculations??
    Yes, that's what I meant. It's easy when the calculations you perform in any simulation step just depend on time and some parameters that remain constant over the simulation run (of course it's absolutely fine to change parameters between simulation runs). If, however, your calculations also depend on results obtained in the previous step, it may become more complicated, since the timespan elapsed between steps may not be constant (which actually is the gist of the game loop approach).

    But don't do any actual drawing in the timer tick handler. Just update your simulation parameters and call Invalidate(), which will result in OnPaint() being called, where you then do the actual drawing based on the updated simulation parameters, much like you're already doing in the code you uploaded.

    To reduce CPU load caused by repainting, you may just invalidate the area that actually has changed rather than the entire form, sort of what is described in http://forums.codeguru.com/showthrea...92#post2005192. But CPU load probably won't be so dramatic either way.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center