This method reads huge file. nodes are in first part of a file, ways in second. _nodes uses in different function for distances computations. I don't like ReadWays do both tasks. Improve it and suggest better approaches       

Func<IEnumerable<Way>> readAction = () => reader.ReadWays(osmFilePath, _nodes);
Func<Way, WayDistance> computeAction = (x) => new WayDistance(x.Id, x.Name, gaussDistance.Calculate(x))
Task.WhenAll(readAction, computeAction);
....
 public IEnumerable<Way> ReadWays(string osmFilePath, Dictionary<long, Node> nodes)
        {

            long wayStarted = -1;
            bool isFirstWayReached = false;

            int batchSize = 1000;
            int count = 0;

            using (FileStream fs = new FileStream(osmFilePath, FileMode.Open, FileAccess.Read))
            using (XmlReader reader = XmlReader.Create(fs, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore }))
            {

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "node")
                    {
                        var node = new Node();
                        node.Id = long.Parse(reader.GetAttribute("id") ?? "0");
                        node.Latitude = double.Parse(reader.GetAttribute("lat") ?? "0");
                        node.Longitude = double.Parse(reader.GetAttribute("lon") ?? "0");

                        nodes.Add(node.Id, node);
                    }
                    else
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "way")
                        {

                            long wayId = long.Parse(reader.GetAttribute("id") ?? "0");
                            string name = null;
                            bool isPrimary = false;
                            var nodeRefs = new List<long>();

                            while (reader.Read())
                            {
                                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "way")
                                    break;

                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    if (reader.Name == "nd")
                                    {
                                        long nodeRef = long.Parse(reader.GetAttribute("ref") ?? "0");
                                        nodeRefs.Add(nodeRef);
                                    }
                                    else if (reader.Name == "tag")
                                    {
                                        string key = reader.GetAttribute("k");
                                        string value = reader.GetAttribute("v");

                                        if (key == "highway" && value == "primary")
                                            isPrimary = true;
                                        else if (key == "name")
                                            name = value;
                                    }
                                }
                            }


                            if (!isPrimary || name == null || nodeRefs.Count < 2)
                            {
                                continue;
                            }
                            else
                            {
                                yield return new Way(wayId, name, nodeRefs);
                            }
                        }
                    }
                }


                //return wayStarted;
            }