make viewWillDisapear wait for animation to finish - ios6

So my issue is that in my viewWillDisapear I call a method that runs a animation (a bounce on the main view) but it doesn't wait for the animation to finish (since this runs in it's own thread). I need a way to make the execution stop till the uiAnimation is finished. i tried sleep() but for some reason this also pauses the actual animation.
What I realy need to happen is for the view to have a small bounce before it is slid of the screen. I am also open to any sugestions on how i can achieve this differently.

Related

Is there an action that sends an event when an object stops moving

So I have an enemy who randomly chooses between 4 destinations and I want him to play his idle animation when he stops moving, is there anyway this can be achieved.

How to animate CN1 Slider progress on load

Please can you help me work out how to build a Codenameone Slider control that simply animates its Progress when it renders initially, so the user sees the progress bar increase over the course of a few seconds.
My actual implementation is to use Chen's awesome ArcProgress control to show how far something has grown, so as the control renders the arc is filled to its 70% or so level over a few seconds. I have the image above all built and working so far.
Many thanks
You just need to invoke setValue to indicate the current position. I'm guessing you don't see the progress moving because you're doing the progress on the EDT thus blocking painting.
All paint operations are performed on the EDT thread and so if your loading/processing code runs on that thread (the main thread) you're effectively blocking the paint operations. There's a long discussion of this in the EDT section of the developer guide.

Angular progress bar and timer (linked)

I am trying to add countdown timer into an AngularJS app (a small quiz)
That part is probably easy enough.. The catch is that I want a progress bar at the bottom of the page to sync up with the countdown timer (So the bar either increases or decreases as the timer runs out)
Not looking for a complete answer, just someone to point me in the right direction of to how to approach the task as I feel a bit clueless.
Once again, thank you in advance, kind Angular wizards!

wpf progress bar slows 10x times serial port communications... how could be possible that?

I know that this could look a dumb question, but here's my problem.
I have a worker dialog that "hides" a backgroundworker, so in a worker thread I do my job, I report the progress in a standard way and then I show the results in my WPF program.
The dialog contains a simply animated gif and a standard wpf progress bar, and when a progress is notified I set Value property. All lokks as usual and works well for any kind of job, like web service calls, db queries, background elaboration and so on.
For my job we use also many "couplers", card readers that reads data from smart card, that are managed with native C code that access to serial port (so, I don't use .NET SerialPort object).
I have some nunit tests and I read a sample card in 10 seconds, but using my actual program, under the backgroundworker and showing my worker dialog, I need 1.30 minutes to do the SAME job.
I struggled into problem for days until I decide to remove the worker dialog, and without dialog I obtain the same performances of the tests!
So I investigated, and It's not the dialog, not the animated gif, but the wpf progress bar!
Simply the fact that a progress bar is shown (so, no animation, no Value set called, nothing of nothing) slows serialport communicatitons.
Looks incredible? I've tested this behavior and it's exactly what happens.
What you describe sounds completely normal. Updating a progress bar's value once is a relatively trivial task, but if your code is performing a large number of operations, then updating the progress bar each time can end up taking much more total time than just the operations would themselves.
If your code performs, say, 10,000 operations, try setting your progress bar's maximimum value to 10, and only update the bar every 1,000 operations.
Another possibility is to set the bar's value using BeginInvoke instead of Invoke (if this is how you're doing it in the first place). Invoke blocks until the invoked method is completed, which means each operation in your loop has to wait for the progress bar to be updated before continuing.
I always use the following code for updating progress bars (has to be run in the UI thread)
private int UpdateCount = 0;
public void UpdateProgress(int value)
{
// We are updating every tenth time.
if (((UpdateCount % 10) == 0)) {
ProgressBar1.Value = value;
}
UpdateCount += 1;
}

How to work out when WPF Storyboard has completed a Seek and has been drawn onscreen?

I have a WPF storyboard that I want to step through frame-by-frame (for a variable framerate). At each frame my intention is to story a bitmap of the drawn storyboard state.
To this end I am trying to employ the following method:
this.CurrentStoryboard.Begin(this);
this.CurrentStoryboard.Pause(this);
//call a function (SEEKFUNC) which calls the following method for (increasing "frameNumber"s):
this.CurrentStoryboard.Seek(this, TimeSpan.FromSeconds(((double)frameNumber) / c_FrameRate), TimeSeekOrigin.BeginTime);
//wait for drawing to complete at point
SaveFrame(this.saveCanvas);
//call SEEKFUNC with frameNumber++
What I am struggling with however is finding out when the Storyboard has completed and been rendered. Can I assume that this will have been successfully completed by the second subsequent call to CompositionTarget.Rendering? Is there another, neater way?
Take a look at this: http://blogs.msdn.com/saveenr/archive/2008/09/22/wpf-xaml-saving-an-animation-as-an-avi-video-file.aspx
From that code it looks like calling UpdateLayout will finish seeking the animation.

Resources