Skip to content

1.4 pre 99 : Exception in Multithreading #256

@manuprendlair

Description

@manuprendlair

Hello,

I got System.Exception' dans Itinero.dll ("Cannot read elements with an id outside of the accessor range.") in a Parallel.For

Here my code:

int max = 100;
Parallel.For(0, max, ctr =>
{
if (TestMultiThreading(v_origine, v_dest)) Interlocked.Increment(ref v_numFailed);
});

        

public bool TestMultiThreading(Point p_Origin, Point p_Destination)
		{
			bool v_Fail = false;
			try
			{
				Route route = new Route();
				Profile v_profile = Vehicle.Car.Shortest();
				Coordinate v_pointA, v_pointB;
				v_pointA = new Coordinate((float)p_Origin.CoordonneeY, (float)p_Origin.CoordonneeX);
				v_pointB = new Coordinate((float)p_Destination.CoordonneeY, (float)p_Destination.CoordonneeX);
				RouterPoint start, end;
				const float DistanceMaxProj = 500.0F;
				Router router = new Router(v_routerDB);
				start = router.Resolve(v_profile, v_pointA, DistanceMaxProj);
				end = router.Resolve(v_profile, v_pointB, DistanceMaxProj);
				route = router.Calculate(v_profile, start, end);
			}
			catch (Exception exc)
			{
				v_Fail = true;
			}

			return v_Fail;
		}

Regards.

Emmanuel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions