clojure.lang.Agent.AddError C# (CSharp) Méthode

AddError() public méthode

Add an error.
public AddError ( Exception e ) : void
e System.Exception The exception to add.
Résultat void
        public void AddError(Exception e)
        {
            _errors = RT.cons(e, _errors);
        }

Usage Example

Exemple #1
0
            /// <summary>
            /// Worker method to execute the action on a thread.
            /// </summary>
            /// <param name="state">(not used)</param>
            /// <remarks>corresponds to doRun in Java version</remarks>
            void ExecuteAction(object state)
            {
                try
                {
                    Var.pushThreadBindings(RT.map(RT.AGENT, _agent));
                    Agent.Nested = PersistentVector.EMPTY;

                    bool hadError = false;

                    try
                    {
                        object oldval = _agent.State;
                        object newval = _fn.applyTo(RT.cons(_agent.State, _args));
                        _agent.SetState(newval);
                        _agent.notifyWatches(oldval, newval);
                    }
                    catch (Exception e)
                    {
                        // TODO: report/callback  (Java TODO)
                        _agent.AddError(e);
                        hadError = true;
                    }

                    if (!hadError)
                    {
                        releasePendingSends();
                    }

                    bool             popped = false;
                    IPersistentStack next   = null;
                    while (!popped)
                    {
                        IPersistentStack prior = _agent._q.Get();
                        next   = prior.pop();
                        popped = _agent._q.CompareAndSet(prior, next);
                    }

                    if (next.count() > 0)
                    {
                        ((Action)next.peek()).execute();
                    }
                }
                finally
                {
                    Nested = null;
                    Var.popThreadBindings();
                }
            }