Home > Microsoft .Net Development Tips > .NET Developer > Reasons to move to .NET
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Reasons to move to .NET


Jimmy Nilsson
04.02.2002
Rating: -3.75- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


 

Reasons to move to .NET
Jimmy Nilsson

Many developers are thinking about moving to .NET, yet may not understand good reasons to do so. Never fear: In this tip, excerpted from InformIT, Jimmy Nilsson discusses one such reason -- multi threading.

Jimmy Nilsson is the author of .NET Enterprise Design with Visual Basic .NET and SQL Server 2000.


Most VB6 developers who have read about .NET, or who have played with it, have a long list of reasons why you should upgrade to Visual Basic .NET or C#. Common reasons include support for implementation inheritance, an improved versioning schema, and object constructors.

Some developers also see the support for free threading as a major improvement over the VB6 Single-Threaded Apartment (STA) multi-threading model. However, other developers warn about the dangers that free threading will add. Using free threading certainly can do some serious damage, but it also opens up new possibilities for VB developers when building COM+ components. We can use the object pooling service, for example, and the synchronization service in COM+ makes it quite easy to write thread-safe components. (If you leave out sharing objects between requests by using the object-per-request mode, you're also relieved of most of the threading issues.)

Apart from not having the possibility of using object pooling, just what's so bad about STA? I'm not going to go into a long description about different threading models here. Let's just use a simplified description and say that an STA thread can't be used by a second request when it's servicing a first request. It doesn't matter whether the two requests are about two different objects, or even classes. Instead, the second request is put on hold until the first request finishes. You might ask why the second request would try to use the same thread. One reason is that COM+ uses a thread-pool per server application, and the size of the STA thread-pool is approximately 10 threads multiplied by the number of CPUs. So if you only have one CPU in your server, there are only 10 threads that can service the requests of the application. When all those threads are busy with long requests, new requests have to wait. (You can increase the size of the thread pool -- see Microsoft Knowledge Base article Q303071 -- but the basic problem is always there. It's also the case that when you don't see long requests you'll have a lot of thread-switching overhead.)

If all the threads are busy, new requests have to wait. This doesn't apply for Multi-Threaded Apartment (MTA) threads, because there's no upper limit for that thread pool. But there's one even more irritating problem when it comes to STA threads. Assume that two users' objects are sharing the same STA and all other STAs are unoccupied. The first user then starts a long operation. Even though there are many idle threads, requests from the second user have to wait.

The blocking behavior of STAs has been well known for a long time, but I think Microsoft's support engineers have recently been more eager to point out the problems of STAs at the COM+ newsgroups. They refer to Knowledge Base article Q291837, "INFO: Do Not Make Blocking Calls from an STA Component." In this article, Microsoft says that a blocking call is a call that calls a back end (such as SQL Server). So what does this mean? It basically says that you shouldn't use VB6 for writing COM+ components that talk to a database server. Oops! My guess is that 90% of the COM+ components in the world do just that -- they're written in VB6 and talk to a database server (directly or indirectly).

The good news is that this problem goes away when Visual Basic .NET is used because then you write free-threaded COM+ components!


To read the article from which this tip is excerpted, click over to InformIT. You have to register there, but the registration is free.

For More Information


Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
.NET Developer
How to speed up Visual Studio 2008's slow WPF designer
How to list fonts in WPF using markup extensions and data templates
How to convince management to buy Microsoft Visual Studio 2008
Microsoft webcast series previews new Visual Studio 2010 features
New features in Windows 7 bring new UI considerations for developers
User Account Control (UAC): How to develop code for standard users
Introduction to Vista's user account control (UAC) for developers
Visual Studio 2008 code metrics tools will help keep code clean
Downloadable MSDN library released for VS 2008 SP 1
Widgetbox provides good example of how to use Facebook Developer Toolkit

VB 6 to VB .NET Migration
On managing a .NET Framework 1.x migration
Tool translates VB .NET code to Java
Microsoft unveils VB 2005 'Power Packs'
Mini-Guide: The VB.NET Development Environment, Part 3
Mini-Guide: The VB.NET Development Environment, Part 2
Mini-Guide: The VB.NET Development Environment, Part 1
Put VB.NET events in the hands of AddHandler
Choosing VB.NET or C# Learning Guide
Object-Oriented Programming in VB .NET Learning Guide
Quiz: What do you know about VB 6 migration?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
.NET  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts