clojure.lang.Future.deref C# (CSharp) Method

deref() public method

public deref ( ) : object
return object
        public object deref()
        {
            _t.Join();
            if (_cancelled)
            {
                throw new FutureAbortedException();
            }
            if (_error != null)
            {
                throw new InvalidOperationException("Future has an error", _error);
            }
            return _value;
        }

Same methods

Future::deref ( long ms, object timeoutValue ) : object

Usage Example

Esempio n. 1
0
        public void PropagatesExceptions()
        {
            AFnImpl fn = new AFnImpl();
            fn._fn0 = () => { throw new Exception("future exception"); };

            Future f = new Future(fn);
            try
            {
                f.deref();
                Assert.Fail("expected future exception");
            }
            catch (Exception ex)
            {
                Expect(ex.Message, EqualTo("Future has an error"));
                Expect(ex.InnerException, Is.Not.Null);
                Expect(ex.InnerException.Message, EqualTo("future exception"));
            }

            // Same result for subsequent derefs.
            try
            {
                f.deref();
                Assert.Fail("expected future exception");
            }
            catch (Exception ex)
            {
                Expect(ex.Message, EqualTo("Future has an error"));
                Expect(ex.InnerException, Is.Not.Null);
                Expect(ex.InnerException.Message, EqualTo("future exception"));
            }
        }
All Usage Examples Of clojure.lang.Future::deref