Author Options:

how do i run a timer on a separate thread in visual basic so it doesn't lag? Answered


I am currently writing a program that records the mouses position over a 256x192 px box, then spits it out every 67ms in the form of dsgamemaker xds code which can be pasted into the project code, to make a sprite move on the exact same path as the mouse moved during the recording.

A problem i am having however is that the timer event i am using to move the cursor representative sprite ( which moves with the D-Pad up down left right), when i begin recording, the sprite moves very very slowly because the frame rate is so very slow. as a separate timer event from the recorder, it moves slow, but when all the code is as one entire timer, it moves at literally 3 pixels per second.

however this does not affect the generated sprite cut-scene.

Ive read that if i put this timer  on a separate thread, that it will run independently from the other timer which will stop the lagging. but the problem is that i cannot find a single example online which shows how to do this, and the ones that do show, don't work.

does someone know how i can make the timer run on a different thread? or even a different core for that matter, so it doesnt lagg?

Im puzzled as to how other applications can do this, increasing a value one at a time, at such a high rate, when the timer event, will never do that. is there some other way to run looping code like a timer event?
Your help would be greatly appreciated.
ill post the application soon to show you exactly whats happening

also im running VB 2008 express



7 years ago

You didn't indicate where else you've tried, but you may want to post your question to: http://stackoverflow.com/

I use the site from time to time when I get stuck...
They get more than enough traffic, that sometimes you find your answer before you even have to post the question. But if you do have to ask for help, you don't have to mark your question as "solved" until you get an answer that works.

The more specific your question, the better answers you'll get over there.

Good Luck.


7 years ago

I recall that sometimes you need a doevents call in your timer intensive stuff to allow some interrupts to work properly.

Sorry if that's not exactly what you're looking for; I've not used separate threads in vb before.