NSLogWriter ArgumentOutOfRangeException

As you can see in the attached screenshot, I am checking the length of sb and if it's not 0, it will execute the Replace command.

However, somehow the Length is zero and it is executing the Replace command and throwing an exceptiong. But there is content in '_str', so I don't understand how the length could be zero...

Is this a bug in StringBuilder?

Below is another bug, probably related to the one above. You can see that I commented out the Replace command and now it is failing on ToString().

Answers


How are you using NSLogWriter ? Like this (see my blog):

Console.SetOut (new NSLogWriter ());
Console.WriteLine ("we're back in action!");

or are you creating (and using) your own instance ? e.g.

var log = new NSLogWriter ();
log.WriteLine ("uho");

If you use the second way then you need to handle multithreading yourself. E.g. another log could have flushed (and cleared sb) between the Length check and the Replace call.

System.Console avoids this because the NSLogWriter is wrapped with TextWriter.Synchronized, e.g. something similar to:

stdout = new NSLogWriter ();
stdout = TextWriter.Synchronized (stdout);

Need Your Help

why does my table show up in one cell

html css

My table keeps show up in one cell, not sure what i did wrong. anyone willing to look and let me know where i went wrong.