0

I have a program which needs to do two separate functions simultaneously. The first is updating the picturebox with a new Bitmap, the second function is a simple function which is effectively instantaneous.

However, because of the delay in updating the picturebox, there is a noticeable delay between the two. The basic code is as follows:

this.pictureBox1.Image = bmp;
this.Invalidate();
OtherFunction();

I have disabled double buffering, and tried all kinds of .Update(), .Refresh(), Application.DoEvents(), but nothing seems to make it any faster.

From my research it seems that setting the Invalidate Flag just means that next time something comes round looking for invalidated forms, it will update it. Is there a way to trigger this manually?

I would rather not introduce a Thread.Sleep() line unless absolutely necessary

poy
  • 10,063
  • 9
  • 49
  • 74
  • You have given us no clue about what that other function is doing and what goes wrong? – Sriram Sakthivel Jan 07 '14 at 15:20
  • Sorry Sriram. The other function is not especially relevant, except that it needs to run as close as possible to the picturebox updating as possible. The problem is that even if I run it after the `.Invalidate()` line, it still happens severl milliseconds beforehand. – Ed Heywood-Lonsdale Jan 07 '14 at 15:22

1 Answers1

0

Have you seen this question? Maybe you haven't tried the exact magic sequence of calls that force the control to update.

Community
  • 1
  • 1
Matt
  • 2,682
  • 1
  • 17
  • 24