mohasad

hi ,
In my application i am using a thread . i am fetching data in mainthread . in the mean while i have used a separate thread to animate a object . but the animation thread is called only once .. so only the image is visible . could anyone resolve this problem .
thanks
sadiq



Re: Smart Devices VB and C# Projects regarding the animation in separate thread

AlexY

Any updates to the UI thread must be done through Control.Invoke.





Re: Smart Devices VB and C# Projects regarding the animation in separate thread

mohasad

hi Alexy,
in my application i am not using any controls like button . simply i have passed the name of the method as a delegate to the thread when initialising the thread . the code is as follows :
Thread animate = new Thread (new ThreadStart(method));
animate.start();
the method increments the x and y position of the image .

thanks
sadiq





Re: Smart Devices VB and C# Projects regarding the animation in separate thread

Ilya Tumanov

That would work as long as your animation is done in memory and not shown on the screen. If you need to show it (which is usually the point of animation) you have to use Control.Invoke() to at least update the screen which would wait for UI thread which turns your threading pretty much useless.






Re: Smart Devices VB and C# Projects regarding the animation in separate thread

mohasad

i couldnt understand your point of view . can u make it clear . using the above code i have specified , the animation is working . but now the application after some time automatically getting exit . its showing out of memory exception .
thanks
sadiq





Re: Smart Devices VB and C# Projects regarding the animation in separate thread

Ilya Tumanov

The fact is what attempt to change UI from the thread would lead to hang (on V1) or exception (on V2).

As to OOM, that is a separate problem which is likely a result of failure to dispose of bitmaps properly.