using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Threading; 
 | 
  
 | 
namespace Shared.SimpleControl.Phone 
 | 
{ 
 | 
    /// <summary> 
 | 
    /// 通过灯光设备类型,显示出所有房间的灯光 
 | 
    /// </summary> 
 | 
    public class UserDeviceToSocket : FrameLayout 
 | 
    { 
 | 
        /// <summary> 
 | 
        /// 当前设备界面 
 | 
        /// </summary> 
 | 
        static UserDeviceToSocket curView; 
 | 
        VerticalScrolViewLayout bodyScrolView; 
 | 
  
 | 
        /// <summary> 
 | 
        /// 构造函数 
 | 
        /// </summary> 
 | 
        public UserDeviceToSocket () 
 | 
        { 
 | 
            curView = this; 
 | 
            BackgroundColor = SkinStyle.Current.MainColor; 
 | 
            readAllStatus (); 
 | 
        } 
 | 
  
 | 
        Thread readEnergyThead; 
 | 
        bool readEnergy = false; 
 | 
  
 | 
        List<Common> EnergtLightList = new List<Common> (); 
 | 
  
 | 
        public override void RemoveFromParent () 
 | 
        { 
 | 
            curView = null; 
 | 
            readEnergy = false; 
 | 
            if (readEnergyThead != null) 
 | 
                readEnergyThead.Abort (); 
 | 
            base.RemoveFromParent (); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 更新能源设备数据 
 | 
        /// </summary> 
 | 
        /// <param name="updataType">更新类型(bit0-bit5) 2: 电压  3: 电流   10:功率   11:电能       (BIT 6-7    0:2bytes  1:1bytes 2:4bytes)</param> 
 | 
        /// <param name="updataFlag">更新的设备标记</param> 
 | 
        /// <param name="energy">更新的值</param> 
 | 
        public static void UpdataEnergy (int updataType , string updataFlag, int energy) 
 | 
        { 
 | 
            Application.RunOnMainThread (() => { 
 | 
                if (curView == null) { 
 | 
                    return; 
 | 
                } 
 | 
                if (curView.bodyScrolView.Decelerating) { 
 | 
                    return; 
 | 
                } 
 | 
                for (int i = 0; i < curView.bodyScrolView.ChildrenCount; i++) { 
 | 
                    if (curView.bodyScrolView.GetChildren (i).GetType () == typeof (FrameLayout)) { 
 | 
                        var lightRow = (FrameLayout)curView.bodyScrolView.GetChildren (i); 
 | 
                        var o = lightRow.Tag; 
 | 
                        if (o != null && o.ToString () == updataFlag) { 
 | 
                            for (int j = 0; j < lightRow.ChildrenCount; j++) { 
 | 
                                if (lightRow.GetChildren (j).GetType () == typeof (Button)) { 
 | 
                                    var btn = (Button)lightRow.GetChildren (j); 
 | 
                                    if (btn.Tag != null) { 
 | 
                                        if (updataType == 10) { 
 | 
                                            if (btn.Tag.ToString () == DeviceType.LightEnergySocket.ToString () + "_Voltage" || btn.Tag.ToString () == DeviceType.LightEnergySwitch.ToString () + "_Voltage") { 
 | 
                                                btn.Text = energy.ToString () + " W"; 
 | 
                                            } 
 | 
                                        } else if (updataType == 11) { 
 | 
                                            if (btn.Tag.ToString () == DeviceType.LightEnergySocket.ToString () + "_Electric" || btn.Tag.ToString () == DeviceType.LightEnergySwitch.ToString () + "_Electric") { 
 | 
                                                btn.Text = ((double)(Convert.ToDouble (energy) / 10)).ToString () + " kw.h"; 
 | 
                                            } 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 更新当前灯光 
 | 
        /// </summary> 
 | 
        public static void UpdateStatus (string updataFlag, byte brightness) 
 | 
        { 
 | 
            #region 更新用户主界面灯光点亮总数 
 | 
            Application.RunOnMainThread (() => { 
 | 
                int brighingCount = 0; 
 | 
                foreach (var room in Room.Lists) { 
 | 
                    if (string.IsNullOrEmpty(room.Name)) { 
 | 
                        continue; 
 | 
                    } 
 | 
                    foreach (var light in room.DeviceList) { 
 | 
                        if (light.Type == DeviceType.LightSwitchSocket) { 
 | 
                            if ((light as LightSwitch).CurrentBrightness == 100) 
 | 
                                brighingCount++; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                UserDeviceView.UpdataDeviceCountNumber (brighingCount, Language.StringByID (R.MyInternationalizationString.ElectricalControl)); 
 | 
            }); 
 | 
            #endregion 
 | 
            System.Threading.Tasks.Task.Run (() => { 
 | 
                Application.RunOnMainThread (() => { 
 | 
                    if (curView == null) { 
 | 
                        return; 
 | 
                    } 
 | 
                    for (int i = 0; i < curView.bodyScrolView.ChildrenCount; i++) { 
 | 
                        if (curView.bodyScrolView.GetChildren (i).GetType () == typeof (FrameLayout)) { 
 | 
                            var lightRow = (FrameLayout)curView.bodyScrolView.GetChildren (i); 
 | 
                            var o = lightRow.Tag; 
 | 
                            if (o != null && o.ToString () == updataFlag) { 
 | 
                                for (int j = 0; j < lightRow.ChildrenCount; j++) { 
 | 
                                    if (lightRow.GetChildren (j).GetType () == typeof (Button)) { 
 | 
                                        var btn = (Button)lightRow.GetChildren (j); 
 | 
                                        if (brightness == 0) { 
 | 
                                            btn.IsSelected = false; 
 | 
                                        } else { 
 | 
                                            btn.IsSelected = true; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                    curView.updateLigthOnCount (); 
 | 
                }); 
 | 
            }); 
 | 
        } 
 | 
        /// <summary> 
 | 
        /// 显示当前多少个灯是亮的 
 | 
        /// </summary> 
 | 
        void updateLigthOnCount () 
 | 
        { 
 | 
            Application.RunOnMainThread (() => { 
 | 
                if (curView == null) 
 | 
                    return; 
 | 
                for (int i = 0; i < curView.bodyScrolView.ChildrenCount; i++) { 
 | 
                    if (curView.bodyScrolView.GetChildren (i).GetType () == typeof (RowLayout)) { 
 | 
                        var roomRow = (RowLayout)curView.bodyScrolView.GetChildren (i); 
 | 
                        if (roomRow.Tag != null) { 
 | 
                            foreach (var room in Room.Lists) { 
 | 
                                if (string.IsNullOrEmpty(room.Name)) { 
 | 
                                    continue; 
 | 
                                } 
 | 
                                if (roomRow.Tag.ToString () == room.Name) { 
 | 
                                    int oCount = 0; 
 | 
                                    foreach (var light in room.DeviceList) { 
 | 
                                        if (light.Type == DeviceType.LightSwitchSocket) { 
 | 
                                            if ((light as LightSwitch).CurrentBrightness == 100) 
 | 
                                                oCount++; 
 | 
                                        } 
 | 
                                    } 
 | 
  
 | 
                                    for (int j = 0; j < roomRow.ChildrenCount; j++) { 
 | 
                                        if (roomRow.GetChildren (j).GetType () == typeof (EditText)) { 
 | 
                                            var et = (EditText)roomRow.GetChildren (j); 
 | 
                                            et.Text = oCount.ToString (); 
 | 
                                            if (oCount > 0) { 
 | 
                                                et.TextColor = SkinStyle.Current.SelectedColor; 
 | 
                                            } else 
 | 
                                                et.TextColor = SkinStyle.Current.TextColor1; 
 | 
                                        } 
 | 
                                        if (roomRow.GetChildren (j).GetType () == typeof (Button)) { 
 | 
                                            var btn = (Button)roomRow.GetChildren (j); 
 | 
                                            if (oCount > 0) { 
 | 
                                                btn.IsSelected = true; 
 | 
                                            } else { 
 | 
                                                btn.IsSelected = false; 
 | 
                                            } 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
        bool showTip = true; 
 | 
        /// <summary> 
 | 
        /// 控制所有的灯 
 | 
        /// </summary> 
 | 
        /// <param name="b">The blue component.</param> 
 | 
        void controlAllLight (byte b) 
 | 
        { 
 | 
            showTip = true; 
 | 
  
 | 
            System.Threading.Tasks.Task.Run (() => { 
 | 
                try { 
 | 
                    Application.RunOnMainThread (() => { 
 | 
                        MainPage.Loading.Start ("Sending..."); 
 | 
                    }); 
 | 
                    foreach (var room in Room.Lists) { 
 | 
                        if (string.IsNullOrEmpty (room.Name)) { 
 | 
                            continue; 
 | 
                        } 
 | 
                        foreach (var common in room.DeviceList) { 
 | 
                            //controlDeviceIndex++; 
 | 
                            byte [] returnBytes = null; 
 | 
                            if (common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySocket) { 
 | 
                                returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, common.SubnetID, common.DeviceID, new byte [] { common.LoopID, b, 0, 0 }); 
 | 
                                if (showTip) { 
 | 
                                    Application.RunOnMainThread (() => { 
 | 
                                        if (returnBytes == null) { 
 | 
                                            string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); 
 | 
                                            var btnTip = new Button () { 
 | 
                                                Height = Application.GetRealHeight (140), 
 | 
                                                Text = common.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), 
 | 
                                                BackgroundColor = 0xFF000000, 
 | 
                                                //TextColor = 0xFF000000 
 | 
                                            }; 
 | 
                                            MainPage.MainFrameLayout.AddChidren (btnTip); 
 | 
                                            btnTip.MouseUpEventHandler += (sender, e) => { 
 | 
                                                btnTip.RemoveFromParent (); 
 | 
                                                //MainPage.MainFrameLayout.Remove (btnTip); 
 | 
                                            }; 
 | 
  
 | 
                                            System.Threading.Tasks.Task.Run (() => { 
 | 
                                                System.Threading.Thread.Sleep (3000); 
 | 
                                                Application.RunOnMainThread (() => { 
 | 
                                                    btnTip.RemoveFromParent (); 
 | 
                                                    //MainPage.MainFrameLayout.Remove (btnTip); 
 | 
                                                    showTip = false; 
 | 
                                                }); 
 | 
                                            }); 
 | 
                                        } 
 | 
                                    }); 
 | 
                                } 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } catch (Exception ex) { 
 | 
                    Console.WriteLine (ex.Message); 
 | 
                } finally { 
 | 
                    Application.RunOnMainThread (() => { 
 | 
                        MainPage.Loading.Hide (); 
 | 
                    }); 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
        /// <summary> 
 | 
        /// 通过设备类型方式选择设备 
 | 
        /// </summary> 
 | 
        public void ShowAllRoomLights () 
 | 
        { 
 | 
            #region 标题 
 | 
            var topView = new FrameLayout () { 
 | 
                Y = Application.GetRealHeight(36), 
 | 
                Height = Application.GetRealHeight (90), 
 | 
            }; 
 | 
            AddChidren (topView); 
 | 
  
 | 
            var title = new Button () { 
 | 
                TextAlignment = TextAlignment.Center, 
 | 
                Text = Language.StringByID (R.MyInternationalizationString.ElectricalControl), 
 | 
                TextSize = 19, 
 | 
                TextColor = SkinStyle.Current.TextColor1, 
 | 
            }; 
 | 
            topView.AddChidren (title); 
 | 
  
 | 
            var logo = new Button () { 
 | 
                Width = Application.GetRealWidth (154), 
 | 
                Height = Application.GetRealHeight (90), 
 | 
                X = Application.GetRealWidth (486), 
 | 
                UnSelectedImagePath = MainPage.LogoString, 
 | 
            }; 
 | 
            topView.AddChidren (logo); 
 | 
            var back = new Button () { 
 | 
                Height = Application.GetRealHeight (90), 
 | 
                Width = Application.GetRealWidth (85), 
 | 
                UnSelectedImagePath = "Item/Back.png", 
 | 
                SelectedImagePath = "Item/BackSelected.png", 
 | 
            }; 
 | 
            topView.AddChidren (back); 
 | 
            back.MouseUpEventHandler += (sender, e) => { 
 | 
                (Parent as PageLayout).PageIndex -= 1; 
 | 
  
 | 
            }; 
 | 
            #endregion 
 | 
  
 | 
            #region 全开-全关 
 | 
            var powerView = new FrameLayout () { 
 | 
                Height = Application.GetRealHeight (110), 
 | 
                BackgroundColor = SkinStyle.Current.TitileView, 
 | 
                Y = topView.Bottom 
 | 
            }; 
 | 
            AddChidren (powerView); 
 | 
            var btnAllON = new Button () { 
 | 
                Width = Application.GetRealWidth (320), 
 | 
                TextSize = 16, 
 | 
                TextID = R.MyInternationalizationString.ALLON, 
 | 
                TextColor = SkinStyle.Current.TextColor1, 
 | 
                SelectedTextColor = SkinStyle.Current.SelectedColor, 
 | 
            }; 
 | 
            powerView.AddChidren (btnAllON); 
 | 
            var btnAllOff = new Button () { 
 | 
                Width = Application.GetRealWidth (320), 
 | 
                X = btnAllON.Right, 
 | 
                TextSize = 16, 
 | 
                TextID = R.MyInternationalizationString.ALLOFF, 
 | 
                TextColor = SkinStyle.Current.TextColor1, 
 | 
                SelectedTextColor = SkinStyle.Current.SelectedColor, 
 | 
            }; 
 | 
            powerView.AddChidren (btnAllOff); 
 | 
            var btnLine = new Button () { 
 | 
                Width = 1, 
 | 
                BackgroundColor = SkinStyle.Current.White20Transparent, 
 | 
                X = btnAllON.Right, 
 | 
                Y = 1, 
 | 
            }; 
 | 
            powerView.AddChidren (btnLine); 
 | 
  
 | 
            #endregion 
 | 
  
 | 
            bodyScrolView = new VerticalScrolViewLayout () { 
 | 
                Height = Application.GetRealHeight (1136 - 126 - 110), 
 | 
                Y = powerView.Bottom, 
 | 
                BackgroundColor = SkinStyle.Current.ViewColor 
 | 
            }; 
 | 
            AddChidren (bodyScrolView); 
 | 
  
 | 
            updateLigthOnCount (); 
 | 
  
 | 
            #region 显示全部的灯光 
 | 
            int LightCount = 0; 
 | 
            foreach (var room in Room.Lists) { 
 | 
                if (string.IsNullOrEmpty(room.Name)) { 
 | 
                    continue; 
 | 
                } 
 | 
                foreach (var common in room.DeviceList) { 
 | 
                    if (common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySocket) { 
 | 
                        LightCount++; 
 | 
                        var light = common as LightSwitch; 
 | 
                        var lightView = new FrameLayout () { 
 | 
                            Height = Application.GetRealHeight (130), 
 | 
                            Tag = common.CommonLoopID 
 | 
                        }; 
 | 
                        bodyScrolView.AddChidren (lightView); 
 | 
  
 | 
                        //灯名 
 | 
                        var tempDeviceName = new Button () { 
 | 
                            X = Application.GetRealWidth (20), 
 | 
                            TextAlignment = TextAlignment.CenterLeft, 
 | 
                            Text = room.Name + "-" + light.Name, 
 | 
                            TextColor = SkinStyle.Current.TextColor1, 
 | 
                            SelectedTextColor = SkinStyle.Current.TextColor1, 
 | 
                            Enable = false, 
 | 
                        }; 
 | 
                        lightView.AddChidren (tempDeviceName); 
 | 
  
 | 
                        var tempSwitch = new Button () { 
 | 
                            Width = Application.GetMinRealAverage (90), 
 | 
                            Height = Application.GetMinRealAverage (53), 
 | 
                            X = Application.GetRealWidth (640 - 90 - 20), 
 | 
                            Gravity = Gravity.CenterVertical, 
 | 
                            UnSelectedImagePath = "Item/SwitchClose.png", 
 | 
                            SelectedImagePath = "Item/SwitchOpen.png", 
 | 
                            IsSelected = light.CurrentBrightness == 100 ? true : false, 
 | 
                            Tag = light.CommonLoopID 
 | 
                        }; 
 | 
                        lightView.AddChidren (tempSwitch); 
 | 
                        tempSwitch.MouseUpEventHandler += (sender3, e3) => { 
 | 
                            tempSwitch.IsSelected = !tempSwitch.IsSelected; 
 | 
                            if (tempSwitch.IsSelected) { 
 | 
                                light.CurrentBrightness = 100; 
 | 
                            } else { 
 | 
                                light.CurrentBrightness = 0; 
 | 
                            } 
 | 
                            Control.ControlBytesSend (Command.SetSingleLight, light.SubnetID, light.DeviceID, new byte [] { light.LoopID, light.CurrentBrightness, light.DelayTimeHeight, light.DelayTimeLow }); 
 | 
                        }; 
 | 
  
 | 
                        if (light.CurrentBrightness == 100) { 
 | 
                            tempSwitch.IsSelected = true; 
 | 
                        } 
 | 
                        Button btnEnergy = new Button () { 
 | 
                            Width = Application.GetRealWidth (90), 
 | 
                            Height = Application.GetRealHeight (30), 
 | 
                            X = tempSwitch.X, 
 | 
                            Y = tempSwitch.Bottom, 
 | 
                            TextColor = SkinStyle.Current.TextColor1, 
 | 
                            SelectedTextColor = SkinStyle.Current.TextColor1, 
 | 
                            Tag = common.Type.ToString () + "_Voltage", 
 | 
                            Text = "0 W" 
 | 
                        }; 
 | 
                        lightView.AddChidren (btnEnergy); 
 | 
                        EnergtLightList.Add (common); 
 | 
  
 | 
                        //if (common.Type == DeviceType.LightEnergySwitch) { 
 | 
                            Button btnElectric = new Button () { 
 | 
                                Width = Application.GetRealWidth (200), 
 | 
                                Height = Application.GetRealHeight (35), 
 | 
                                X = Application.GetRealWidth (320), 
 | 
                                Y = tempSwitch.Bottom, 
 | 
                                TextColor = SkinStyle.Current.TextColor1, 
 | 
                                SelectedTextColor = SkinStyle.Current.TextColor1, 
 | 
                                TextAlignment = TextAlignment.CenterRight, 
 | 
                                Tag = common.Type.ToString () + "_Electric", 
 | 
                                Text = "0 kw.h" 
 | 
                            }; 
 | 
                            lightView.AddChidren (btnElectric); 
 | 
                        //} 
 | 
  
 | 
                        Button btnEnergyNull = new Button () { 
 | 
                            Y = Application.GetRealHeight (127), 
 | 
                            Height = Application.GetRealHeight (3), 
 | 
                            BackgroundColor = SkinStyle.Current.MainColor, 
 | 
                            SelectedBackgroundColor = SkinStyle.Current.MainColor, 
 | 
                        }; 
 | 
                        lightView.AddChidren (btnEnergyNull); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
  
 | 
            readEnergyThead = new Thread ((obj) => { 
 | 
                while (readEnergy) { 
 | 
                    foreach (var c in EnergtLightList) { 
 | 
                        Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 10, c.LoopID }, SendCount.Zero); 
 | 
                        Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 11, c.LoopID }, SendCount.Zero); 
 | 
                    } 
 | 
                    Thread.Sleep (10000); 
 | 
                } 
 | 
            }); 
 | 
            if (EnergtLightList.Count > 0) { 
 | 
                readEnergyThead.Start (); 
 | 
                readEnergy = true; 
 | 
            } 
 | 
            if (LightCount > 0) { 
 | 
                btnAllON.MouseUpEventHandler += (sender, e) => { 
 | 
                    btnAllON.TextColor = SkinStyle.Current.SelectedColor; 
 | 
                    btnAllOff.TextColor = SkinStyle.Current.TextColor1; 
 | 
                    Alert alert = new Alert ("", 
 | 
                                             Language.StringByID (R.MyInternationalizationString.SureOpenAllSocket), 
 | 
                                             Language.StringByID (R.MyInternationalizationString.Cancel), 
 | 
                                             Language.StringByID (R.MyInternationalizationString.Confrim)); 
 | 
                    alert.Show (); 
 | 
                    alert.ResultEventHandler += (sender2, e2) => { 
 | 
                        if (e2) { 
 | 
                            controlAllLight (100); 
 | 
                        } 
 | 
                    }; 
 | 
                }; 
 | 
                btnAllOff.MouseUpEventHandler += (sender, e) => { 
 | 
                    btnAllON.TextColor = SkinStyle.Current.TextColor1; 
 | 
                    btnAllOff.TextColor = SkinStyle.Current.SelectedColor; 
 | 
                    Alert alert = new Alert ("", 
 | 
                                             Language.StringByID (R.MyInternationalizationString.SureCloseAllSocket), 
 | 
                                             Language.StringByID (R.MyInternationalizationString.Cancel), 
 | 
                                             Language.StringByID (R.MyInternationalizationString.Confrim)); 
 | 
                    alert.Show (); 
 | 
                    alert.ResultEventHandler += (sender2, e2) => { 
 | 
                        if (e2) { 
 | 
                            controlAllLight (0); 
 | 
                        } 
 | 
                    }; 
 | 
                }; 
 | 
            } 
 | 
            #endregion 
 | 
        } 
 | 
  
 | 
        static System.Threading.Thread thread; 
 | 
        /// <summary> 
 | 
        /// 读取设备状态 
 | 
        /// </summary> 
 | 
        public static void readAllStatus (bool isRead = false) 
 | 
        { 
 | 
            if (isRead) { 
 | 
                foreach (Room room in Room.Lists) { 
 | 
                    if (string.IsNullOrEmpty(room.Name)) { 
 | 
                        continue; 
 | 
                    } 
 | 
                    var list = room.DeviceList.FindAll ((obj) => { 
 | 
                        return obj.Type == DeviceType.LightSwitchSocket; 
 | 
                    }); 
 | 
                    foreach (Common common in list) { 
 | 
                        common.LastUpdateTime = DateTime.MinValue; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            if (thread != null) { 
 | 
                thread.Abort (); 
 | 
            } 
 | 
            thread = new Thread (() => { 
 | 
                try { 
 | 
                System.Collections.Generic.List<string> readList = new System.Collections.Generic.List<string> (); 
 | 
                foreach (Room room in Room.Lists) { 
 | 
                    if (string.IsNullOrEmpty(room.Name)) { 
 | 
                        continue; 
 | 
                    } 
 | 
                    var list = room.DeviceList.FindAll ((obj) => { 
 | 
                        return obj.LastUpdateTime.AddMinutes (Common.Time) <= DateTime.Now && obj.Type == DeviceType.LightSwitchSocket; 
 | 
                    }); 
 | 
                    foreach (Common common in list) { 
 | 
                        var s = common.Type + "_" + common.SubnetID + "_" + common.DeviceID; 
 | 
                        //已经读取过当前设备就不再读取 
 | 
                        if (readList.Contains (s)) { 
 | 
                            continue; 
 | 
                        } 
 | 
                        readList.Add (s); 
 | 
                        Control.ControlBytesSendHasReturn (Command.ReadLightEquipmentAllLoopBrightness, common.SubnetID, common.DeviceID, new byte [] { }); 
 | 
                    } 
 | 
                } 
 | 
             } catch { } finally { 
 | 
                    thread = null; 
 | 
                } 
 | 
            }); 
 | 
            thread.Start (); 
 | 
        } 
 | 
    } 
 | 
} 
 |