Share via

How to stop timer in timer.elapsed

Shay Wilner 1,746 Reputation points
2023-09-12T20:11:10.1666667+00:00

Hello

in platforrm xamarin android

I try to show a blade cutting some material. the blade moves from right to left and when it reaches

the left edge of the panel it has to stop .

The problem is that the blade stop only if put a breakpoint at line timerblade.Stop()

private void Timerblade_Elapsed(object sender, ElapsedEventArgs e)
        {
            RunOnUiThread(() =>
            {
                var plx = (RelativeLayout.LayoutParams )plxareatop.LayoutParameters;
                var bld = (RelativeLayout.LayoutParams)blade.LayoutParameters;
                var plt = (RelativeLayout.LayoutParams)plate.LayoutParameters;
                bld.LeftMargin -= 2;
                if( bld.LeftMargin <= plx.LeftMargin + plt.LeftMargin+ 50)
                    timerblade.Stop();
                blade.LayoutParameters = bld;
            });
        }

thanks

Developer technologies | .NET | Xamarin
0 comments No comments

1 answer

Sort by: Most helpful
  1. Shay Wilner 1,746 Reputation points
    2023-09-13T04:33:29.5066667+00:00

    I found my mistake the i have two timer and have forgot to stop the other

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.