/// <summary> /// 处理返回值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ht_FileWatchEvent(object sender, CompleteEventArgs e) { int lrcCount = 0; list = httpSer.Result2Deserializer(e.Node, out lrcCount); if (lrcCount == 0 || list.Count == 0) { Dispatcher.BeginInvoke(() => { JMessBox jb = new JMessBox("没有结果"); jb.Show(); }); } else { //遍历歌词结果列表 list.ForEach(c => { //执行对每个artistid的查询 DoHttpWebRequestArtist(c.artist_id); }); Dispatcher.BeginInvoke(() => { JMessBox jb = new JMessBox(string.Format("搜索到{0}个歌词", lrcCount)); jb.Show(); }); } }
private void ResponseReadySocket(IAsyncResult asyncResult) { try { WebRequest request = asyncResult.AsyncState as WebRequest; WebResponse response = request.EndGetResponse(asyncResult) as HttpWebResponse; result = GetResponseString(response); string keyword = request.RequestUri.Segments.Last(); CompleteEventArgs args = new CompleteEventArgs(result,keyword); FileWatchEvent(this, args); } catch (Exception e) { Console.WriteLine(e.Message); } }
void ht_FileWatchEvent3(object sender, CompleteEventArgs e) { int lrcCount = 0; //序列化作者列表 artistModel = artistSer.Result3Deserializer(e.Node, out lrcCount); //如果作者列表为空则返回 if (lrcCount == 0 || artistModel == null) { return; } //当前作者结果对象 Model.Result2 temp = list.FirstOrDefault(c => c.artist_id.ToString() == e.Node2); //加入到查询结果表 result.Add(new Model.Result2Plus() { sid = temp.sid, song = temp.song, lrc = temp.lrc, artist = artistModel.name, }); //绑定结果表 Dispatcher.BeginInvoke(() => { this.LBResult.DataContext = null; this.LBResult.DataContext = result; }); }
/// <summary> /// 处理返回值2 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ht_FileWatchEvent2(object sender, CompleteEventArgs e) { string lrcStr = e.Node; GetCompleted(lrcStr); }