Esempio n. 1
0
 /// <summary>
 /// Evnet를 수신중인 함수 delegate를 삭제합니다.
 /// </summary>
 /// <param name="id">수신중인 event id 종류입니다</param>
 /// <param name="observer">수신중인 함수 delegate입니다</param>
 public static void RemoveObserver(EventID id, EventObserver observer)
 {
     lock (ObserversAddRemoveQueue)
     {
         Map3 <bool, EventID, EventObserver> newEvent = new Map3 <bool, EventID, EventObserver>(false, id, observer);
         ObserversAddRemoveQueue.Enqueue(newEvent);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Event를 수신할 함수를 추가합니다.
 /// </summary>
 /// <param name="id">수신하고자하는 event id 종류입니다</param>
 /// <param name="observer">Event를 수신하고자하는 함수 delegate 입니다</param>
 public static void AddObserver(EventID id, EventObserver observer)
 {
     lock (ObserversAddRemoveQueue)
     {
         foreach (Map3 <bool, EventID, EventObserver> set in ObserversAddRemoveQueue)
         {
             if (set.d2 == id && set.d3.Equals(observer))
             {
                 return;
             }
         }
         Map3 <bool, EventID, EventObserver> newEvent = new Map3 <bool, EventID, EventObserver>(true, id, observer);
         ObserversAddRemoveQueue.Enqueue(newEvent);
     }
 }
Esempio n. 3
0
 private static void ObserverStateCheck()
 {
     lock (ObserversAddRemoveQueue)
     {
         if (ObserversAddRemoveQueue.Count > 0)
         {
             try
             {
                 cacheLock.EnterWriteLock();
                 while (ObserversAddRemoveQueue.Count > 0)
                 {
                     Map3 <bool, EventID, EventObserver> set3   = ObserversAddRemoveQueue.Dequeue();
                     Map2 <EventID, EventObserver>       result = null;
                     foreach (Map2 <EventID, EventObserver> set2 in Observers)
                     {
                         if (set3.d2 == set2.d1 && set3.d3.Equals(set2.d2))
                         {
                             result = set2;
                             break;
                         }
                     }
                     if (set3.d1 == true)
                     {
                         if (result == null)
                         {
                             Observers.Add(new Map2 <EventID, EventObserver>(set3.d2, set3.d3));
                         }
                     }
                     else
                     {
                         if (result != null)
                         {
                             Observers.Remove(result);
                         }
                     }
                 }
             }
             finally
             {
                 cacheLock.ExitWriteLock();
             }
         }
     }
 }