text:
Q: contents of dictionary class vanishing, possible thread issue? Forgive me but I'm not quite sure where in my code things are going wrong!
I'm working on creating a multithreaded tcp server, and am attempting to store strings using a dictionary. The code looks like this:
class Echo : Iprotocol
{
    public Dictionary<string, string> dictionary = new Dictionary<string, string>();
    private const int BUFFSIZE = 32; //buffer size

    private Socket client_sock; //Socket
    private Ilogger logger; // logger

    public Echo(Socket sock, Ilogger log)
    {
        this.client_sock = sock;
        this.logger = log;
    }
    public string handlewhois(string inname)
    {
        ArrayList entry = new ArrayList();
        string name = inname;
        string message = null;
        if (dictionary.ContainsKey(name) == true)
        {
            entry.Add(System.DateTime.Now + "Dictionary reference found at thread: " + Thread.CurrentThread.GetHashCode());
            message = dictionary[name];
        }
        else
        {
            entry.Add(System.DateTime.Now + "Dictionary reference not found at thread:  " + Thread.CurrentThread.GetHashCode());
            message = "ERROR: no entries found";
        }
        logger.writeEntry(entry);
        return message;
    }
    public string handlewhois(string inname, string inlocation)
    {
        ArrayList entry = new ArrayList();
        string name = inname;
        string location = inlocation;
        string message = null;
        entry.Add(System.DateTime.Now + "Dictionary reference created or updated at thread: " + Thread.CurrentThread.GetHashCode());
        dictionary.Add(name, location);
        message = "OK";
        logger.writeEntry(entry);
        return message;
    }
}

It runs perfectly fine, however as I step through it in debug, I see the the dictionary entry created, however when it gets to the line:
logger.writeEntry(entry);
It suddenly vanishes, with dictionary not containing any values.
I think it may have something to do with the multithreading but honestly I have no idea!

A: Dictionary is not thread safe - please consider using ConcurrentDictionary instead.
From the Dictionary documentation:

A Dictionary can support multiple readers concurrently,
  as long as the collection is not modified. Even so, enumerating
  through a collection is intrinsically not a thread-safe procedure. In
  the rare case where an enumeration contends with write accesses, the
  collection must be locked during the entire enumeration. To allow the
  collection to be accessed by multiple threads for reading and writing,
  you must implement your own synchronization.
For a thread-safe alternative, see ConcurrentDictionary.
Public static (Shared in Visual Basic) members of this type are thread
  safe.

See this SO question and answer for more information.

redpajama_set_name: RedPajamaStackExchange


text:
Thompson Family History
Telling the story straight, no matter how painful or unsavory.
By Boyce Thompson
On the Road: The Treacherous Touch the Wig Tour
Driving south through the mountains of North Carolina
My self-appointed mission: To drive all the way to New Orleans for a special viewing of clothes belonging to my third great grand uncle Judah P. Benjamin. With any luck, the Touch the Wig tour would end with a precious co-mingling of DNA, so that genealogists many years from now would know that I'd made the vital connection. The things we do for posterity.
I admit to special feelings as I set out through the South, across the great state of Virginia, then through North Carolina, Georgia, Alabama, and Florida on my way to Louisiana and the State Museum. Most of them, though, involved fighting off pure boredom or fatigue as we drove along Interstate highways built long after Judah P.'s time. But as we drove deeper into the South, it was mildly entertaining to think that the Louisiana plantation owner who had served as Secretary of State for the Confederacy had surely known some of this countryside.
I couldn't loose blessed focus, even as the monotony of the journey threatened to turn my brain into cheese grits. The special viewing had been arranged by an intrepid librarian, Georgia Chadwick, who like me had developed a special interest in things belonging to Judah P. Benjamin. Georgia had also found that editors at the New Orleans Times-Picayune had used a desk belonging to the great confederate statesman, a desk that was now in possession of the State Museum. We wouldn't be seeing the desk on this journey.
Judah P. Benjamin's roll-top desk, bought for use at his plantation, was sold at auction after the Civil War. It was used by four editors of the New Orleans Times-Democrat and one editor of the Times-Picayune, which lent it to the Louisiana State Museum
We'd be seeing the clothes that the great Judah P. had worn during his reincarnation as an English barrister, after being driven out of his adopted country, The United States, like an over-matched portly fox pursued by Union hounds. He was forced to ride to safety on blessed horse, then hitch a ride on a boat to England, pretending to be a cook, donning an apron and smearing his face with grease. My lofty quest begged big questions. How big would his pants be? What size shoes did he wear? How grotesque would his sweat-encased, powder-laden wig be after all these years? Could it have turned into a biscuit or to rock?
We wouldn't get the answers unless we could find the secret storage place for textiles and outfits belonging to the State Museum. For that, we would need our librarian guide. We decided as a logistical matter to rendezvous at the Fat Hen for breakfast and plot our course. Over a delicious meal of mushroom omelets and cheese grits, with some delectable homemade bread and jam, and a pot of delicious chicory coffee, it was decided: We would stay at the Fat Hen all day. No, I would follow Georgia downtown to the French Quarter, where we would park in an expensive public lot. There was little choice, given the difficulty of finding free street parking on a Thursday morning. If I didn't have the cash, the lot would take a credit card. Whew. Talk about a close one.
Here's a picture of Judah P. in his barrister's outfit
I quickly found that my German-made car, despite having driven more than 1,000 miles, was more than equal to the test, but what a test it was. New Orleans roads are among the most treacherous in the country. A veritable minefield of potholes and damp crevices threaten the suspension at every turn. Road repairs seem to start–judging cones and signs–yet never to end, interrupted time after time by graft and another excuse to party. Of that, one cannot be sure. But this much is certain: the roads suck.
Hiding our precious valuables in the car, we set out on foot through the party-soaked streets of New Orleans. Strangers approached us, appealed to our vanity, then asked for money. The ploy worked several times. In an all-to-frequent ADD moment, I'm reminded of the blind beggar on the streets of Washington D.C. who successfully pried money from me then managed to find the only unoccupied seat on the Metro. A miracle indeed.
Meanwhile, the ribald sound of a four-piece Dixieland quartet drowned out the making of larcenous plans that no doubt included us. The same menacing forces that produced this grizzled city's dreadful roads resulted in barely passable sidewalks. One false step could be your last. There would be no one to rescue you from the stanky gutters of this party town, redolent with spilled drinks, urine, and fresh barf. Was that a rat?
We inched our way carefully through the streets until Georgia finally spotted our destination. "This is it," she said in a tone barely above a whisper, as she pressed an intercom button to announce we were here. I tried vainly to keep my cover. No one could know that I was a very distant relative of the Great Judah P. They might guess his clothes were inside. "Hi, Steve, it's us," Georgia said, pretty calmly considering our imminent danger.
There was a commotion inside–what could possible be going on?–and then Steve opened the gunmetal grey door. He ushered us quickly inside, presumably before anyone could follow from the street. The building looked like any other storage building. Who would have guessed that it held such precious contents? Steve took us to a storage elevator with a door that opened noisily from top to bottom. This had been the disturbing noise that I had heard.
The ride took less than a minute. Steve opened the doors and we entered another hallway. There, only a few steps away, was the textile and clothing repository for the State Museum. I did a double-take as we approached. It appeared as though many people were inside the storage facility. I reached for my weapon, then realized I never carried one. It was okay. They were mannequins, dressed in Mari Gras party attire. Still, that was a little too close for comfort.
The object of my quest: Judah P. Benjamin's clothes
As Steve led us through the stacks, our bounty came into sight. There, laid out across a long table, were the clothes worn by Judah P. when he practiced law in England. Starting with barely a penny to his name, Benjamin had adeptly risen through the legal ranks, achieving the position of Queen's Counsel in 1872. To think, these were the threads that he had worn at the time. Incredible. Benjamin had died in 1884. Alma Kruttschnitt, his beloved niece, had given the clothes to the museum in the 1920s. I secretly hoped that they had been cleaned since then.
The clothes were not in the best condition. In fact, the museum several years before had received a $15,ooo estimate to repair them. What could they have been thinking when they didn't immediately spend the money to create a lifelike display in a state museum? Probably that it wasn't worth the money to clothe a some stupid mannequin with the suit of a dead lawyer. Wise decision.
There it all was — his silk tie and stockings, his kid gloves and glove stretcher, his grotesque wig and wig box. His shoes complete with a silly, girlish buckle, looked to be about a size 7. His pants, on the other hand, were at least a size 42. The conclusion was inescapable: This dude was fat. Tea and crumpets served him ill. His frayed silk vest, no doubt stretched to the max during his time, was nearly beyond repair.
I reached out to touch the wig, a menacing tumble of grey fiber, sitting there so inertly, but no doubt concealing dead weasels. I couldn't bring myself to touch it; it was just too gross. Slowly, ever so slowly I moved my index figure toward the object of my quest. I tried not to think of the vermin it hid….
Reaching out to touch the wig...
A wig rib roast
All his stuff again
A duplicate
His kid gloves
A glove widening kit
His wool robe, very nice.
His vest needs work
His shoes were about a size 7, if that
I'd say he was at least a 40-waist
An up-close view of his wig, which is probably coarse enough to clean a frying pan
See–this stuff belonged to Judah P. This is his wig box.
The silk portions of his outfit were nearly beyond repair
Buckles were a big deal back then
The object of my quest: Judah P. Benjamin's clothes
Reaching out to touch the wig…
Here's a picture of Judah P. in his barrister's outfit
Judah P. Benjamin's roll-top desk, bought for use at his plantation, was sold at auction after the Civil War. It was used by four editors of the New Orleans Times-Democrat and one editor of the Times-Picayune, which lent it to the Louisiana State Museum
Filed Under: Benjamin Tagged With: Alma Kruttschnitt, Judah P. Benjamin
Go Ahead, Search for Gold ...
Kruttschnitt
Simmers
Ough
McCullen
de Mendes
Filor
Kithcart
Latest from Boyce
Little to Nothing Remains of Philip Benjamin's Time in Charleston
1:42 pm 13 Oct 2019
Was King Tut's Curse the Real Cause of W.B. Thompson's Demise?
12:53 pm 21 Jul 2019
No Surprise: Isaie Gingras Was Buried in a Catholic Cemetery
Explore the History
Benjamin Biddle Boner Boyce Clark Cunningham Deathbed Letters de Mendes Doty Families Fiction Filor Folklore Gingras Herman Hickman Hohenlohe Kithcart Kock Kruttschnitt Libby Maguire McCullen Mercier Miscellaneous Murray Ough Pickering Simmers St. Martin Thompson Wigmore Williams Wilson Woodhouse Wright
Judah P. Benjamin's Homes Largely Forgotten In New Orleans
Rancho Joaquina Needed a Facelift Before It Could be Shown to the Public
Hatevil Nutter Was A Cruel Religious Hypocrite
Old Letter Is Probably Fake, But Still Makes Good Reading
John Libby Lost His Homes and Two Children in King Phillip's War
Copyright © 2020 · Thompson Family History · Boyce Thompson Media, LLC

redpajama_set_name: RedPajamaCommonCrawl


Manbat, the UK's leading automotive battery distributor, has launched its latest product directory in the form of the 2013/14 Lucas Battery Catalogue, which is the first edition to be completely designed and compiled by Manbat.
To accompany this excellent publication, Manbat has also produced a range of point-of-sales (POS) material to inform the trade and consumers alike to the depth of the range and the many practical applications that the products are compatible with.
The high quality publication is produced in full colour throughout and each Lucas battery product group – automotive, commercial vehicle & agricultural, industrial, golf, motorcycle, leisure & marine, mobility and emergency standby power (fire, security & electrical systems) – is superbly presented with colour photographs and a detailed description of the specifications, benefits and applications that are most appropriate to that particular group of batteries.