示例#1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            deferral = taskInstance.GetDeferral();
            //
            // TODO: Insert code to perform background work
            //
            // If you start any asynchronous methods here, prevent the task
            // from closing prematurely by using BackgroundTaskDeferral as
            // described in http://aka.ms/backgroundtaskdeferral
            //

            gps = new GPS();

            await gps.ConnectToUART(9600);

            if (gps.Connected)
            {
                gps.SetSentencesReporting(0, 1, 0, 0, 0, 0);
                CancellationTokenSource ReadCancellationTokenSource = new CancellationTokenSource();
                await gps.ReadAsync(ReadCancellationTokenSource.Token);
            }

            deferral.Complete();
        }