public UIDevice()
 {
     InitializeComponent();
     th_OnlineDevice = new Thread(RunThreadFunctionOnlineDevice);
     th_OnlineDevice.IsBackground = true;
     th_MediaPlay = new Thread(RunThreadFunctionMediaPlay);
     th_MediaPlay.IsBackground = true;
     th_MediaPlay.SetApartmentState(ApartmentState.STA);
     client = new alta_client();
     client.ConnectErr += client_ConnectErr;
     client.ConnectSuccess += client_ConnectSuccess;
     client.RecieveDataEvent += client_RecieveDataEvent;
     this.media = null;
 }
        private void UIRootView_Unloaded(object sender, RoutedEventArgs e)
        {
            try
            {
                this.th_OnlineDevice.Abort();
                this.th_OnlineDevice = null;
            }
            catch (Exception)
            {

            }
            try
            {
                this.th_MediaPlay.Abort();
                this.th_MediaPlay = null;
            }
            catch (Exception)
            {

            }
            this.client = null;
        }