What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

How to start/stop gps.GpsMove?

Status
Not open for further replies.

tictoc

Member
Joined
Sep 21, 2012
Messages
380
Reaction score
5
Hi,

i do have one main thread with the windows forms ui and a start/stop button.
I do start a gps.GpsMove in a separate task or thread (tried both). I do use CancelMoveTo() to stop moving.
But it works only one time. If i try to start the next gps.GpsMove nothing happens.

Any idea what i may have missed?

/tictoc
 
Hi.
Are you aborting the thread? is it background? join?

trowing some bone, not really idea of what is going on there...
 
U can abort other thread, or use gps.SuspendGpsMove();
 
Everything works fine the first time i do start and stop. But after that i cannot start a gpsMove again.
 
Code:
        Thread _threadMove;

        private void GoToPoint(string point)
        {
            StopThreadMove();
            _threadMove = new Thread(() =>
            {
                while (!_gps.GpsMove(point))
                    Thread.Sleep(100);
            });

            _threadMove.Start();
        }

        private void StopThreadMove()
        {
            if (_threadMove != null &&
                _threadMove.IsAlive &&
                _threadMove.ThreadState != ThreadState.Stopped)
            {
                _threadMove.Abort();
                _threadMove.Join();
            }
        }

now, bind your Start button to GoToPoint(name) method, and your Stop button to StopThreadMove method.. it will work
 
Thanks a lot for this example. I will try it out.
What i have not used so far is the .Join()

And i do start GpsMove whithout such a while loop.
Can you explain why we do need it?
 
Based on this code i have rewritten mine and now it works fine. Thanks again!

What i did need to add is "CancelMoveTo()". Without this i do keep running up to the next gps point before the movement stops.
 
Status
Not open for further replies.
Back
Top