Beispiel #1
0
 public void AddMyPlurk()
 {
     this._IsAlive = true;
     do
     {
         plurks UnReadplurks = this.UnReadPlurk;
         //計算執行緒數量
         int iThreadCount = (UnReadplurks.Count % iPlurkCountPerThread == 0)
                             ? (UnReadplurks.Count / iPlurkCountPerThread)
                             : ((UnReadplurks.Count / iPlurkCountPerThread) + 1);
         List<Thread> ThreadList = new List<Thread>();
         for (int i = 1; i <= iThreadCount; i++)
         {
             Thread Thread = new Thread(new ParameterizedThreadStart(Process));
             ThreadList.Add(Thread);
             //計算此執行緒需處理的plurk,將之加入collection
             plurks plurks = new plurks();
             for (int j = (i - 1) * iPlurkCountPerThread; j < i * iPlurkCountPerThread; j++)
             {
                 if (j >= UnReadplurks.Count) break;
                 plurk plurk = UnReadplurks[j];
                 plurks.Add(plurk);
             }
             Thread.Start(plurks);
         }
         #region thread terminating
         bool blnAllThreadIsDead = false;
         do
         {
             if (ThreadList.Count == 0)
             {
                 blnAllThreadIsDead = true;
                 break;
             }
             foreach (Thread Thread in ThreadList)
             {
                 if (Thread.IsAlive)
                 {
                     blnAllThreadIsDead = false;
                     break;
                 }
                 else
                 {
                     blnAllThreadIsDead = true;
                     break;
                 }
             }
         }
         while (!blnAllThreadIsDead);
         #endregion
         if (blnAllThreadIsDead) this._IsAlive = false;
     } while (this._IsAlive);
 }
Beispiel #2
0
        /// <summary>
        /// 取得未讀取的Plurk
        /// </summary>
        /// <param name="mApi"></param>
        /// <returns></returns>
        public static plurks GetUnReadPlurk(PlurkApi.PlurkApi mApi)
        {
            plurks returnPlurks = new plurks();
            returnPlurks = mApi.getUnreadPlurks(DateTime.Now,200);
            #region "取私噗"
            foreach (plurk plurk in mApi.getPlurks(DateTime.Now,100,PlurkTypeFilter.only_private))
            {
                bool addYN = true;
                foreach (plurk checkP in returnPlurks)
                {
                    if (checkP.plurk_id == plurk.plurk_id)
                    {
                        addYN = false;
                        break;
                    }

                    if (checkP.is_unread != 1)
                    {
                        addYN = false;
                        break;
                    }
                }
                if (addYN)
                    returnPlurks.Add(plurk);
            }
            #endregion
            return returnPlurks;
        }