Пример #1
0
        public override void Post(SendOrPostCallback d, object state)
        {
            if (d == null)
            {
                throw new ArgumentNullException("d");
            }

            Interlocked.Increment(ref _callCount);
            Interlocked.Increment(ref _postCount);
            d.DynamicInvoke(state);
        }
Пример #2
0
        public void Catch(SendOrPostCallback codeBlock)
        {
            _Exception = null;
            try
            {
                // need 1 argument, because it is a SendOrPostCallback
                codeBlock.DynamicInvoke(1);

                _Success = true;
            }
            catch (Exception ex)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine("ExceptionCatcher.Succeeded failure", ex.ToString());
#endif
                _Exception = ex;
                _Success   = false;
            }
        }
Пример #3
0
        public object?Catch(SendOrPostCallback codeBlock)
        {
            Exception = null;
            try
            {
                // need 1 argument, because it is a SendOrPostCallback
                var output = codeBlock.DynamicInvoke(1);
                Success = true;
                return(output);
            }
            catch (Exception ex)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine("ExceptionCatcher.Succeeded failure", ex.ToString());
#endif
                Exception = ex;
                Success   = false;
            }
            return(null);
        }