N
NickP
Hi there,
I've made a few animated controls but would like to check on the correct
procedure for doing so as unfortunately every now and then, without warning,
I recieve a GDI+ Exception stating that the graphics object is kin use
elsewhere.
Basically my user control has the following styles set,
AllPaintingInWmPaint and UserPaint. When my control recieves a string array
it starts scrolling each string in the array in a marquee fashion. I have a
stop function which I use to be able to stop the animation when changing the
list.
All of my drawing is performed in a separate thread as it is a constant
loop and I do not want to lock the controls thread. The thread is
synchronised using manual reset events and is impossible to enter twice.
The stop function is also synchronised and will lock the calling thread
until the animation is completely stopped.
The graphics object that the exception is occuring on is SyncLock'ed
every time it is used and is only declared for the life time of the
function, yet I am informed every now and then that it is in use elsewhere,
I can't see that this is the case.
Of course, I could drop down to GDI and eliminate this problem all
together but I would rather just re-implement my code so that it is done
*correctly*
I have tried alternative methods of running an FPS based animation loop
within a control before but this requires that drawing be performed within
the Paint event, which obviously has an impact in performance on the
controls thread, I did not like doing this in an application as it was too
heavy.
Have any of you got any suggestions as to how I can either fix this
problem I am getting, or implement an animated control in a different way
that would provide rock solid performance.
Thanks a million in advance!
Nick.
I've made a few animated controls but would like to check on the correct
procedure for doing so as unfortunately every now and then, without warning,
I recieve a GDI+ Exception stating that the graphics object is kin use
elsewhere.
Basically my user control has the following styles set,
AllPaintingInWmPaint and UserPaint. When my control recieves a string array
it starts scrolling each string in the array in a marquee fashion. I have a
stop function which I use to be able to stop the animation when changing the
list.
All of my drawing is performed in a separate thread as it is a constant
loop and I do not want to lock the controls thread. The thread is
synchronised using manual reset events and is impossible to enter twice.
The stop function is also synchronised and will lock the calling thread
until the animation is completely stopped.
The graphics object that the exception is occuring on is SyncLock'ed
every time it is used and is only declared for the life time of the
function, yet I am informed every now and then that it is in use elsewhere,
I can't see that this is the case.
Of course, I could drop down to GDI and eliminate this problem all
together but I would rather just re-implement my code so that it is done
*correctly*
I have tried alternative methods of running an FPS based animation loop
within a control before but this requires that drawing be performed within
the Paint event, which obviously has an impact in performance on the
controls thread, I did not like doing this in an application as it was too
heavy.
Have any of you got any suggestions as to how I can either fix this
problem I am getting, or implement an animated control in a different way
that would provide rock solid performance.
Thanks a million in advance!
Nick.