Posted By: Ron Jacobs | Apr 29th, 2006 @ 7:35 AM | 17,314 Views | 3 Comments

Several years ago I climbed a high mountain to meet a guru atop. He promised that if I would spend months studying his ways that one day I too would become a threading master. I would learn the ways of threads, thread pools, the mutex, the semaphore and lock. I would one day learn to avoid the dreaded race condition and emerge as one of the few who understand the mysteries of threading. After a moment I said… nah – I’ll just call Jeff Richter.

Links

-Ron

Media Downloads:
Rating:
0
0

Hi Jeff (& Ron Smiley),

 

I found the show very interesting, and I hope you have time for a few questions.

1) So to call a web service using async I/O I just use one of the Begin methods, and thats it? I dont have to launch a thread or anything?

2) What do I do for other resources like Files or a COM method call?

Best regards,
Niels Tindbæk

1) That's right. Just call a BeginXxx method. Do not launch your own thread.
2) The FileStream class offers BeginRead/BeginWrite methods. Use these. For COM methods, you must call them synchronously; or you can spawn a separate thread which calls them synchronously but to the rest of the app it looks like they're being called asynchronously.
Hi Jeff,

As per your article on msdn mag every object has a syncBlockIndex that is used when we lock an object during thread sync, from another webcast on msdn about CLR internals I remember you saying that the same syncBlockIndex is used by garbage collector to mark objects as accessible, what happen when an object is locked and garbage collector runs?

Thanks,
Navneet
Microsoft Communities