Exemplo n.º 1
0
 static void AutoCruiseSchedulerManager_SchedulerUpdated(object sender, EventArgs e)
 {
     lock (rcLocker)
     {
         receivers.Select(l => l.Value)
         .Where(l => AutoCruiseSchedulerManager.GetScheduler(l.AccountInfo) == null)
         .ToArray()
         .ForEach(l =>
         {
             RemoveReceive(l.ListUserScreenName, l.ListName);
             RegisterReceive(l.ListUserScreenName, l.ListName);
         });
     }
     if (waitings.Count > 0)
     {
         var wa = waitings.ToArray();
         waitings.Clear();
         wa.ForEach(t => RegisterReceive(t.Item1, t.Item2));
     }
 }
Exemplo n.º 2
0
        public static void RegisterReceive(string listUser, string listName)
        {
            System.Diagnostics.Debug.WriteLine("** LIST LISTEN START:@" + listUser + "/" + listName);
            listName = NormalizeListName(listName);
            var fullname = BuildListName(listUser, listName);

            lock (rcLocker)
            {
                if (referenceCount.ContainsKey(fullname))
                {
                    referenceCount[fullname]++;
                }
                else
                {
                    var target = AccountStorage.Get(listUser);
                    if (target == null)
                    {
                        target = AccountStorage.GetRandom(ai => ai.IsFollowingList(listUser, listName), true);
                    }
                    var tscheduler = target != null?AutoCruiseSchedulerManager.GetScheduler(target) : null;

                    if (tscheduler == null)
                    {
                        // スケジューラがまだない
                        // スケジューラが更新されるまで待つ
                        waitings.Add(new Tuple <string, string>(listUser, listName));
                        return;
                    }
                    var task = new ListReceiveTask(target, listUser, listName);
                    receivers.Add(fullname, task);
                    tscheduler.AddSchedule(task);
                    Task.Factory.StartNew(() => ListStorage.Get(listUser, listName));
                    referenceCount.Add(fullname, 1);
                }
            }
        }