コード例 #1
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
        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);
                }
            }
        }
コード例 #2
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
 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);
     }
 }
コード例 #3
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
 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);
     }
 }
コード例 #4
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
 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);
         }
     }
 }
コード例 #5
0
ファイル: ProgressTracker.cs プロジェクト: dbremner/tiny
        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));
                }
            }
        }
コード例 #6
0
ファイル: ProgressTracker.cs プロジェクト: dbremner/tiny
 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);
         }
     }
 }
コード例 #7
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
 public IAsyncResult BeginInvoke(SinkCallback <T> callback)
 {
     return(SafeInvoke.BeginInvoke(m_invoke, () => callback(this)));
 }
コード例 #8
0
ファイル: Sink.cs プロジェクト: dbremner/tiny
 public void Invoke(SinkCallback <T> callback)
 {
     SafeInvoke.Invoke(m_invoke, () => callback(this));
 }