evelib icon indicating copy to clipboard operation
evelib copied to clipboard

EveCrest: Threading NullreferenceExcepion EveCrest

Open hrkrx opened this issue 8 years ago • 5 comments

I tried to boost my requestspeed with threading and ran into the following error:

System.AggregateException wurde nicht behandelt.
  HResult=-2146233088
  Message= At least one error...
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at eZet.EveLib.EveCrestModule.EveCrest.Load[T](Href`1 uri, String[] parameters)
       at ~.Updater.<>c__DisplayClass0_0.<Update>b__3() in ~\Updater.cs: Line32
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2147467261
       Message= Objectreference no instance and so on
       Source=EveLib.EveCrest
       StackTrace:
            at eZet.EveLib.EveCrestModule.RequestHandlers.CachedCrestRequestHandler.<RequestAsync>d__48`1.MoveNext()
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at eZet.EveLib.EveCrestModule.EveCrest.<requestAsync>d__91`1.MoveNext()
       InnerException: 

This may be a bug because when i run only one thread its working and if i put enough delay into my algorithm its also working (most of the time).

The code to reproduce this error:


        public void Update()
        {
            eZet.EveLib.EveCrestModule.EveCrest ec = new eZet.EveLib.EveCrestModule.EveCrest();
            ec.EnableRootCache = false;
            var allregions = ec.GetRoot().Query(r => r.Regions);
            foreach (var item in allregions.AllItems())
            {
                eZet.EveLib.EveCrestModule.Models.Links.Href<eZet.EveLib.EveCrestModule.Models.Resources.Region> regionHref = item.Href;
                new Thread(() =>
                {
                    Console.WriteLine("Starting Thread");
                    eZet.EveLib.EveCrestModule.EveCrest ecT = new eZet.EveLib.EveCrestModule.EveCrest();
                    ecT.EnableRootCache = false;

                   //ERROR spawning here
                    var region = ecT.Load(regionHref, new string[] { });
                    foreach (var cons in region.Constellations)
                    {
                        var constellation = ecT.Load<eZet.EveLib.EveCrestModule.Models.Resources.Constellation>(cons.Uri, new string[] { });
                        foreach (var sys in constellation.Systems)
                        {
                            var system = ecT.Load<eZet.EveLib.EveCrestModule.Models.Resources.SolarSystem>(sys.Uri, new string[] { });
                            foreach (var pl in system.Planets)
                            {
                                var planet = ecT.Load<eZet.EveLib.EveCrestModule.Models.Resources.Planet>(pl.Uri, new string[] { });
                            }
                        }
                    }
                }).Start();
            }

hrkrx avatar Feb 20 '16 19:02 hrkrx