News

VB Developers adjust as .NET puts on new threads

[FEBRUARY 25, 2003/ADT'S PROGRAMMERS REPORT] - Threading often seems the game of C programmers, one in which Visual Basic adherents are relegated to the sidelines. With .NET, that is changing. This is good news and bad news, advises an application development expert.

''There were some historical shortcomings with the [VB] tool. We really had no ability to create multithreaded apps short of using convoluted methods,'' said VB specialist Jon Rauschenberger, consultant at Clarity Consulting Inc. With the enhanced version of VB now supporting .NET, the way to threads is readied.

But the power of the new Microsoft .NET platform, and related new tools, can cut both ways, added Rauschenberger, who spoke on the topic at the recent VSLive! Conference in San Francisco.

''It's a double-edged sword,'' said Rauschenberger. ''You can work with threads with VB in .NET, but you need to be sure to understand how they work. And, for first time in a while, developers can write stuff that works in quite a different way than the developer intended.'' With the jerry-rigged workarounds that VB adepts used to make multi-threaded apps in the past, the resulting system ''might be slow, but it wouldn't break,'' he said.

Said Rauschenberger: ''VB developers come from a history where you don't have to worry about how the plumbing [of the deployed application] works. The downside was that you couldn't go in to spawn your own threads.'' And in the new .NET world, ''it's a fairly steep learning curve to figure some of this stuff out,'' he noted.

These issues may relate to larger, long-running questions of object-oriented programming vs. non-object-oriented programming, or system design vs. line-level coding.

''There are a lot of ways you can use threads within an application. If you don't understand things like synchronization, or how the Windows message pump works to paint forms and manage how the actual user interface works, it's very easy to write applications that, at a minimum, crash or in a worst-case scenario actually present inaccurate data to the user,'' Rauschenberger said. C++ developers have been dealing with this kind of thing for years, he added.

So what are some dos and don'ts, asked Programmers Report.

''With synchronization,'' said Rauschenberger, ''you now need to know what it is, when you have to use it and how to implement it using the tools in Visual Basic.''

The biggest thing to be aware of is that, with .NET, the framework will allow you to update a form from a background thread. But in reality, said Rauschenberger, that is something you do not want to do. ''That is because it can cause your app to become unstable at some point,'' he explained.

Finally, Rauschenberger said, make sure you know systems thread pool. ''Understand what it is and how it works before you use it, as opposed to spawning your own threads,'' he advised.

Links:
For other Programmers Report articles, please go to http://www.adtmag.com/article.asp?id=6265

About the Author

Jack Vaughan is former Editor-at-Large at Application Development Trends magazine.

Featured

Most   Popular
Upcoming Events

AppTrends

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.