473,738 Members | 11,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Animated Controls

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,
AllPaintingInWm Paint 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.
Dec 12 '07 #1
1 1697
Typical! After stressing over this for ages I found the true cause of the
issue! My method used to stop the animation was no syncrhonised so at one
point it was being used twice at once. I have now synchronised the method
by using a manual reset event which is rest upon exit of the function, if on
the rare chance 2 threads come in at once, only 1 will get through and has
to wait for the other to finish, hurrah!

So I guess my question is pretty dedundant now unless anyone else is
experiencing similar issues :)

Nick.

"NickP" <a@a.comwrote in message
news:eW******** ******@TK2MSFTN GP05.phx.gbl...
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,
AllPaintingInWm Paint 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.

Dec 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6618
by: Neil | last post by:
Hello, I have an animated gif file that I have in an ImageList control (from Microsoft Common Controls V6). I am trying to get it to display in the taskbar but it only shows the first frame and doesn't animate. I know it can be done because the MSN one animates when you sign in. Anyone know why/how? TIA, Neil.
1
1525
by: Shabam | last post by:
Does dot net support the resizing of animated GIFs? I've heard that it doesn't. Why is that, if it's true?
1
11357
by: Jim S. | last post by:
when i try to insert an animated gif it would not run, just shows as a pic in the view mode, why? and how can i put an animated GIF so it plays when i run the database? thanks jim
9
9717
by: John J. Hughes II | last post by:
Is it possible using Image or Bitmap to build and save an animated GIF file? I am not have a problem saving the GIF file just getting the frames added to it. I did find ImageAnimator but it only seems to deal with showing the GIF and not saving it. Thanks, John
3
6370
by: Ger | last post by:
I have a form with a panel (Panel1) in which I dynamically create picturebox controls. Works like a dream with static pictures, but not when the picturebox.image is an animated gif. GDI+ throws the following error in this case: "An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.windows.forms.dll Additional information: A generic error occurred in GDI+."
10
23566
by: Liz | last post by:
All: Can anyone tell me why my animated GIF does not show up as animated when put into a pictureBox?? Thanks. Liz
7
6332
by: Gary Kaucher | last post by:
At the top of the page on my website http://www.itemlook.com I have an animated gif called "eyeline.gif". It has worked fine in the past, but recently I am unable to get it to work using IE6. All that I get is a box with nothing in it. It almost seems as if the file will not open on my page, let alone animate. It still works fine with my Netscape browser. I am using Windows 98. Any ideas would be appreciated. Thanks,
2
2348
by: Ben Fidge | last post by:
Can anyone recommend any good controls to implement animated buttons. I want something that can perform the following: - Must initially display a static image - When clicked the button must seamlessly display an animated GIF while waiting for the postback to return The idea is to provide some indication to the user that a process is running between page postbacks. For example, at our sites checkout page, we have to exchange data with...
1
3020
by: Kevinst | last post by:
Hello there, I have got a problem and several approaches but none is really staisfying: Lets assume we have a form. On its surface we have got several animations (like a blinking light). This form is not owner drawn. Everything is drawn by child controls. Now we want to go ahead and create an animation that is on top of everything of that form. Lets assume this animation was an arrow that is moving from the top left corner to the...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.