From 18d933b835110e8aa42efa0d4456f61efeb27e5b Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期四, 30 七月 2020 12:00:40 +0800 Subject: [PATCH] 2020-07-30-2 --- HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs | 78 ++++++++++++++++++++++---------------- 1 files changed, 45 insertions(+), 33 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs index 1a23d20..d2b6715 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31MusicModel.cs @@ -17,18 +17,45 @@ } static List<System.Threading.Thread> updataMusicStatesListThread = new List<System.Threading.Thread>(); - /// <summary> /// 璇诲彇闊充箰鐘舵�� /// </summary> public static void ReadMusicStates() { - + RemoveListThread(); + if (GetCollection) + { + for (int i = 0; i < A31MusicModelList.Count; i++) + { + var a31player = A31MusicModelList[i]; + var musicThread = new System.Threading.Thread(() => + { + while (true) + { + System.Threading.Thread.Sleep(1000); + if (!a31player.IsOnLine) + { + continue; + } + SendMethod.ReadStatus(a31player); + } + }) + { IsBackground = true, Name = "A31" }; + musicThread.Start(); + updataMusicStatesListThread.Add(musicThread); + } + } + } + + /// <summary> + /// 绉婚櫎涔嬪墠鐨勭嚎绋� + /// </summary> + public static void RemoveListThread() { var threads = updataMusicStatesListThread.FindAll((obj) => { return obj.Name == "A31"; }); - for (int i =0;i< updataMusicStatesListThread.Count;) + for (int i = 0; i < updataMusicStatesListThread.Count;) { try - { + { var thread = updataMusicStatesListThread[i]; if (thread.IsAlive) { @@ -45,34 +72,11 @@ MainPage.Log("clearA31Threads over"); } } - if (GetCollection) { - for (int i = 0; i < A31MusicModelList.Count; i++) - { - var a31player = A31MusicModelList[i]; - var musicThread = new System.Threading.Thread(() => - { - while (true) - { - System.Threading.Thread.Sleep(1000); - if (!a31player.IsOnLine) - { - continue; - } - //A31MusicModel.ReadMusicStates(); - SendMethod.ReadStatus(a31player); - } - }) - { IsBackground = true, Name = "A31" }; - musicThread.Start(); - updataMusicStatesListThread.Add(musicThread); - } - } - } /// <summary> /// 闊充箰鍒楄〃閲屾槸鍚︽湁闊充箰琚敹钘忚繃 /// </summary> - static bool GetCollection + static bool GetCollection { get { @@ -259,16 +263,15 @@ } } /// <summary> - /// 璁板綍涓绘挱鏀惧櫒鏄惁琚敹钘� + /// 璁板綍涓绘挱鏀惧櫒鏄惁琚敹钘�(绉�妗″畾涔夌殑) /// </summary> public bool MainPlayCollection = false; public Slaves Slave = new Slaves(); - + /// <summary> + /// 璁板綍鏃堕棿 + /// </summary> public static DateTime ProgressDateTime = DateTime.Now; - //static System.Threading.Tasks.Task task; - //闊抽噺鍒楄〃 - //static List<int> volumeCommandList = new List<int> (); public static bool IsJson(string json) { @@ -284,6 +287,14 @@ { return false; } + } + /// <summary> + /// 鑷畾涔夋棩蹇楄緭鍑� + /// </summary> + public static void LogMusic(string str) + { + var time = DateTime.Now; + Console.WriteLine(time + str); } } @@ -329,4 +340,5 @@ public string version = string.Empty; public string uuid = string.Empty; } + } \ No newline at end of file -- Gitblit v1.8.0