nk-gears / markdownsharp

Automatically exported from code.google.com/p/markdownsharp
0 stars 0 forks source link

Is MarkdownSharpe Threadsafe? #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I cannot find anywhere if it is thread safe.

What steps will reproduce the problem?
1. Use a single instance of Markdown in an ASP.NET app
2. Open many pages at once, in each page format some text

What is the expected output? What do you see instead?
I intermittently get the following exception: 
System.Collections.Generic.Dictionary`2.get_Item(TKey key) +12681071
   MarkdownSharp.Markdown.FormParagraphs(String text) in D:\Development\OpenSource\MarkdownSharp\MarkdownSharp\Markdown.cs:437
   MarkdownSharp.Markdown.RunBlockGamut(String text) in D:\Development\OpenSource\MarkdownSharp\MarkdownSharp\Markdown.cs:389
   MarkdownSharp.Markdown.Transform(String text) in D:\Development\OpenSource\MarkdownSharp\MarkdownSharp\Markdown.cs:363

What version of the product are you using? On what operating system?
markdownsharp-20100703-v113.7z

Please provide any additional information below.

Original issue reported on code.google.com by Iain.Rob...@gmail.com on 21 Sep 2011 at 4:19

GoogleCodeExporter commented 9 years ago
It is not threadsafe if you use a single instance.

You should create a new instance for each conversion you do, or at least make 
sure that the same instance isn't used by several threads at once. The former 
should be just fine; the setup cost for creating a new instance isn't very 
high. That's what we do on Stack Overflow.

Since the instance stores information about the current state of the 
conversion, having two threads use the same instance is indeed bound to fail. 
That is by design.

Original comment by ahp...@googlemail.com on 12 Oct 2011 at 2:36

GoogleCodeExporter commented 9 years ago
Thanks for letting me know.

Original comment by Iain.Rob...@gmail.com on 12 Oct 2011 at 10:15