Ejemplo n.º 1
0
        public static void RunAsynchronouslyNoThrow <T>(IEnumerable <Sink <T> > enumerable, Action <T> callback, LogItemType type, string category)
            where T : class
        {
            Action <T> wrappedCb = delegate(T cur)
            {
                try
                {
                    callback(cur);
                }
                catch (Exception ex)
                {
                    Logger.Log(type, category, ex.Message, ex);
                }
            };

            foreach (Sink <T> cur in enumerable)
            {
                try
                {
                    SafeInvoke.BeginInvoke(cur.ISynchronizeInvoke, wrappedCb, cur.ISink);
                }
                catch (Exception ex)
                {
                    Logger.Log(type, category, ex.Message, ex);
                }
            }
        }
Ejemplo n.º 2
0
 public static void RunSynchronously <T>(IEnumerable <Sink <T> > list, Action <T> callback)
     where T : class
 {
     foreach (Sink <T> cur in list)
     {
         SafeInvoke.Invoke(cur.ISynchronizeInvoke, callback, cur.ISink);
     }
 }
Ejemplo n.º 3
0
 public static void RunAsynchronously <T>(IEnumerable <Sink <T> > enumerable, Action <T> callback)
     where T : class
 {
     foreach (Sink <T> cur in enumerable)
     {
         SafeInvoke.BeginInvoke(cur.ISynchronizeInvoke, callback, cur.ISink);
     }
 }
Ejemplo n.º 4
0
 public static void RunSynchronouslyNoThrow <T>(IEnumerable <Sink <T> > enumerable, Action <T> callback, LogItemType type, string category)
     where T : class
 {
     foreach (Sink <T> cur in enumerable)
     {
         try
         {
             SafeInvoke.Invoke(cur.ISynchronizeInvoke, callback, cur.ISink);
         }
         catch (Exception ex)
         {
             Logger.Log(type, category, ex.Message, ex);
         }
     }
 }
Ejemplo n.º 5
0
        internal void OperationFinished()
        {
            lock (m_lock)
            {
                m_finished = true;

                // Close the tracker if it's open.  Make sure to invoke the close so
                // that it occurs on the proper thread
                if (m_tracker != null)
                {
                    // A race condition can occur as to who shuts down first so make sure to swallow
                    // that exception here
                    SafeInvoke.BeginInvokeNoThrow(
                        m_tracker,
                        () => m_factory.DestroyProgressTracker(m_tracker));
                }
            }
        }
Ejemplo n.º 6
0
 private void UpdateTracker()
 {
     if (m_tracker != null && !m_finished)
     {
         // Do a BeginInvoke here because the Invoke operation
         // can very likely block.  Avoid that by using BeginInvoke
         //
         // Since we'll use the current values anyways, don't post multiple BeginInvokes onto
         // the tracker or we could overload it.  Instead post one at a time.
         try
         {
             SafeInvoke.BeginInvoke(m_tracker, new Action(UpdateTrackerDirect));
         }
         catch (Exception ex)
         {
             Logger.Error(FutureLogCategory.BeginInvoke, ex.Message, ex);
         }
     }
 }
Ejemplo n.º 7
0
 public IAsyncResult BeginInvoke(SinkCallback <T> callback)
 {
     return(SafeInvoke.BeginInvoke(m_invoke, () => callback(this)));
 }
Ejemplo n.º 8
0
 public void Invoke(SinkCallback <T> callback)
 {
     SafeInvoke.Invoke(m_invoke, () => callback(this));
 }