public void StartTranlateLrc(LyricCollection lc) { if (GetTransResultThread != null && GetTransResultThread.IsAlive) { return; } GetTransResultThread = new Thread(new ParameterizedThreadStart(TranslateLrcWork)); GetTransResultThread.Start(lc); }
void TranslateLrcWork(object olc) { LyricCollection lc = (LyricCollection)olc; foreach (Lyric lrc in lc.mLrcList) { Lyric newlrc = new Lyric() { Word = lrc.Word, Timeline = lrc.Timeline }; try { newlrc.Word = GetTransResult(newlrc.Word); } catch { newlrc.Word = "Error"; return; } OnTransLrcGet?.Invoke(newlrc); } }