This project has moved and is read-only. For the latest updates, please go here.

Thread safety (FileSvgReader)

Topics: Converters and Runtime, SVG
Feb 3, 2015 at 3:25 PM
The general question is whether the library is thread safe.

Here is the problem that I am seeing (very intermittently) .

I have a page that renders many SvgDrawingCanvas controls in a data grid.

I execute this code:
          WpfDrawingSettings drawingSettings = new WpfDrawingSettings();
            FileSvgReader svgReader = new FileSvgReader(drawingSettings);

            DrawingGroup drawing;
            using (MemoryStream memStream = new MemoryStream())
                memStream.Position = 0;
                drawing = svgReader.Read(memStream);
in each of those controls, and I do it in a BackgroundWorker thread, so 1 BackgroundWorker per control (I then delegate the rendering to the UI thread).

Every once in a while I see an exception popup in line:
                drawing = svgReader.Read(memStream);
"An item with the same key has already been added"

When looking at the stack trace it points back to some Dictionary operations. It does seem to me like in the SvgDocument class there are some static members. I was wondering whether this would explain the problem I am seeing.

What do you think?
Feb 5, 2015 at 2:00 PM
Please, can you provide a simple working sample that illustrates this issue?

Best regards,