Helping Developers Master PowerBuilder Classic and .NET

Yakov Werde

Subscribe to Yakov Werde: eMailAlertsEmail Alerts
Get Yakov Werde: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Blog Post

Migrating MultiThreaded Classic Apps to PB .NET

A minor adventure

The blog is a .NET update for or all of you who are already familiar with multithreading in PowerBuilder Classic using the SharedObject API

Jm recently posted this brief message in the Sybase.Public.PowerBuilder.NET news group, "When we have a multi-thread  programming in PB?? is urgent..."  To which Chris Pollach replied "We have had multi-threaded programming in PowerBuilder since Sybase introduced "SharedObjects" back in the PB version 6.0 release!   :-) Note: I am not sure how well it works under the new WPF model in PB"

I decided to pull out the old trusty SharedObject tutorial I wrote back in PB 8 days, bring it up to version 12 Classic, migrate it over to .NET and see what would happen.

The multithreaded NVO method simulates retrieving a massively large and slow DataWindow in the background while leaving the user interface responsive.  A callback NVO is responsible for setting the state of the user interface when the retrieve completes.  Here's the Classic code for the shared object method

Shared Object Source

The migration and subsequent full build and run proceeded without a hitch. No messages, no warnings. However, the multithreaded run failed to return any data.  A bit of debugging had me notice that the datawindow reference in the callback object was screwed up. (best way I can say it) A brief conversation with a system engineer and a few experiments, led me to notice that the Shared (multithreaded) object was still on the call stack while the callback object's method was getting invoked.  Perhaps I could force the thread off the stack by changing the callback invocation from a Trigger (default) to a Post.  This would allow the thread to exit before the callback was invoked.  The one line change was; of_setdata(l_blob)

Sure enough, this change had the desired effect.  The shared object terminated, leaving the callback object free to do its magic and set the data into the DataWindow control.  Incidentally, I went back to the Classic application and changed the call from a trigger to a Post and verified that it worked in Classic too!

More Stories By Yakov Werde

Yakov Werde, a 25 year IT industry veteran, is a member of TeamSybase and the newly formed Sybase Customer Evangelist Team. Yakov is a recognized author, speaker and trainer who has been designing and delivering PowerBuilder, .NET, EaServer, Web App Development, and Java training for over 14 years to corporate, military and government developers. Prior to discovering his aptitude as an educator, Yakov worked as an architect, project manager and application coder in the trenches of application software development. Yakov holds a Masters in Education with a specialty in instructional design for online learning from Capella University and a BS in math and computer science from Florida International University. Yakov, managing partner of eLearnIT LLC (, authors and delivers workshops and web based eLearning tutorials to guide professional developers toward PowerBuilder Classic and .NET mastery. Follow Yakov on Twitter as @eLearnPB