TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Curtis Stubbs
NA
5
0
Precision Delay
Mar 15 2011 5:12 PM
I'm having a problem with my delay method. The overhead of the delay function is causing my program to slow down way to much. I go from a 0ms delay doing 7000 iterations in 1.466 seconds to a 1 ms delay doing 7000 iterations in 32.318 seconds. The math doesn't add up. Is there any way to get a more precise delay without slowing it down too much?
It's a multi-threaded app updating a simple graph in real-time:
public static void DrawData(int[] data, int size)
{
myBuffer.Graphics.Clear(System.Drawing.Color.White);
int x = 0;
int y = 0;
for (int i = 0; i < size; i++)
{
x = (i + 2) * width;
y = 200 - data[i];
myBuffer.Graphics.DrawLine(bluePen, x, 200, x, y);
}
myBuffer.Render();
System.Threading.Thread.Sleep(delay);
}
Reply
Answers (
5
)
Soda Programming Help
Seperate thread invoke problem