Пример #1
0
 /// <summary>
 /// 关闭,释放资源
 /// </summary>
 public void Dispose()
 {
     if (RealTimeGnssPositioner != null && RealTimeGnssPositioner.Solver != null)
     {
         RealTimeGnssPositioner.Solver.TableTextManager.WriteAllToFileAndClearBuffer();
     }
     RtGnssDataWriter.Dispose();
     this.Close();
 }
Пример #2
0
        /// <summary>
        /// 停止接收数据
        /// </summary>
        public void Stop()
        {
            OnInfoProduced(Name + " 正在检查并停止...");
            if (!NtripDataRequestor.IsCancel)
            {
                NtripDataRequestor.IsCancel = true;
            }
            else
            {
                OnInfoProduced(Name + " 网络访问已经断开");
            }

            if (RealTimeGnssPositioner != null && RealTimeGnssPositioner.Solver != null)
            {
                RealTimeGnssPositioner.Solver.TableTextManager.WriteAllToFileAndClearBuffer();
            }
            if (RtGnssDataWriter != null)
            {
                RtGnssDataWriter.RinexObsFileWriter.Flush();
            }

            Application.DoEvents();
            System.Threading.Thread.Sleep(1000);
            Application.DoEvents();

            //Ok, kill the thread if it is still running.
            if (_NtripThread != null && _NtripThread.IsAlive)
            {
                _NtripThread.Abort(); //Need to add the ability to truly kill a connection that is unresponsive. .Abort() doesn't seem to actually kill the thread
                System.Threading.Thread.Sleep(100);
                Application.DoEvents();

                if (!_NtripThread.IsAlive)
                {
                    OnInfoProduced(Name + " 线程停止成功。");
                }
            }
            else
            {
                OnInfoProduced(Name + " 线程已经停止");
            }

            if (RtGnssDataWriter != null)
            {
                RtGnssDataWriter.Dispose();
                RtGnssDataWriter = null;
            }

            if (BinaryDataWriter != null)
            {
                BinaryDataWriter.Flush();
                BinaryDataWriter.Close();
                BinaryDataWriter = null;
            }
        }