public async void OnTick(IWeiboAccessToken at) { if (_tick++%57 != 0) return; var resp = await WeiboClient.suggestions_statuses_hot_async(at.get(), 20, true, 1, _type); if(++_type == hot_status_type.count) _type = hot_status_type.musement; if (resp.Failed() || resp.Value.Length == 0) return; var queue = new PriorityQueue<long, Status>(); foreach(var s in resp.Value) { queue.Enqueue(EvalMark(s),s); } while (queue.Size > 5) queue.Dequeue(); while(!queue.IsEmpty) { var s = queue.Dequeue(); var ws = new WeiboStatus(); ws.assign_sina(s); await DispatcherHelper.UIDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) (() => { if(statuses.Count > 10) statuses.RemoveAt(0); statuses.Add(ws); })); } }
internal void ReloadSinaV2(Statuses result,bool reload ) { previous_cursor = result.previous_cursor; next_cursor = result.next_cursor; total_number = result.total_number; Debug.WriteLine("noti: {3}, timeline total: {0},prev: {1},next: {2}",total_number,previous_cursor, next_cursor, notifications); if(reload) UiInvoke(() => statuses.Clear()); foreach (var s in result.statuses) { var ws = new WeiboStatus(); ws.assign_sina(s); UiInvoke(() => statuses.Add(ws)); } }