Posted by on in Blogs
A Sink Programming. In this post I demonstrated how you can use an Anonymous Method to "synchronize" a background thread with the main UI thread. However there are times where you don't want to block execution of the thread but still want to have something happen in the main UI thread, asynchronously. For several releases of Delphi there has been the Queue() method on TThread. This allows you to schedule a TThreadMethod (just like Synchronize) to execute on the main UI thread. The difference is that Synchronize wil...
Tags: CodeGear

Posted by on in Blogs
News Flash! Someone has already invented the wheel! I'm sure most, if not all, of you have heard the phrase "Why reinvent the wheel?" Another one I'm very fond of is "Standing on the shoulders of giants." The latter was often heard coming from Distinguished Engineer, Anders Hejlsberg during his tenure at Borland. So, why reinvent the wheel when there are giant shoulders to stand on ;-)? If you've been following along for the last year or so, I've been working on something I loosely refer to as the Delphi Parallel Library. While I've not been blog...
Tags: CodeGear

Posted by on in Blogs
Another &quot;MacGyver&quot; moment Or, "More fun with Generics and Anonymous methods". I'll just leave it up to you whether or not these utility functions are useful, but here they are:type Obj = class class procedure Lock(O: TObject; Proc: TProc); static; class procedure Using<T: class>(O: T; Proc: TProc<T>); static; end; class procedure Obj.Lock(O: TObject; Proc: TProc); begin TMonitor.Enter(O); try Proc(); finally TMonitor.Exit(O); end; end; class procedure Obj.Using<T>(O: T; Pr...
Tags: CodeGear

Posted by on in Blogs
A &quot;Nullable&quot; Post Solving problems can be fun and challenging. What is really challenging is solving a problem using only the tools at hand. During the development of Delphi 2009, there were several language features that were dropped in favor of generics and anonymous methods. One such feature was what we called "managed records." This allowed for some very interesting things where you could now implement a constructor, destructor and several assignment class operators on a record that would be automatically cal...
Tags: CodeGear

Posted by on in Blogs
Retrofitting a classic When Delphi 2 was released targeting the 32bit Windows API there were some new-to-Delphi features of the operating system that opened up some new possibilities; Pre-emptive multi-tasking and multi-threading. Coupled with this "new" concept of a "thread," Delphi introduced the new TThread class that was an abstract base class from which one would derived in order to "wrap" an operating system thread. Along with this new functionality, a rather contrived demo was also introduced that showcased thi...
Tags: CodeGear

Posted by on in Blogs
Multicast Events - the finale In my previous two posts I presented a technique using the new generics language feature of Delphi 2009 to create a typesafe multicast event. In the previous post, I showed how you can create a TMulticastEvent<T> instance and assign it to an event handler for an existing event on a TComponent derived type. Using the existing FreeNotification mechanism, you didn't need to worry about explicitly freeing the multicast event object. What if one of the components in the sink event handlers in t...
Tags: CodeGear

Posted by on in Blogs
Multicast Events - the cleanup In my last post, I introduced a multicast event that uses generics to address the problem of needing to manually declare and implement a new multicaster for each unique event type. If you remember, I referred to some other posts that presented a technique for doing automatic cleanup of both the multicast event object itself and automatic removal of listeners. While the technique presented is indeed very generic and will work for nearly all instances, my only critique is that it carries a fairly ...
Tags: CodeGear

Posted by on in Blogs
Multicast events using generics Ever since before Delphi 1, the (then Delphi only) RAD Studio IDE has been full of home-grown multicast event class types. I usually refer to these as an "event bus." This is from my hardware days when I designed microcontroller based security/access control equipment. A CPU has an "address bus" and a "data bus" which can have one sender and any number of "listeners," not unlike a multicast event. I've been following with interest these series of posts about creating a multicast event class in ...
Tags: CodeGear

Posted by on in Blogs
Tibur&oacute;n - String Theory No, not that String Theory, or even this one. What this is about is an interesting extension to AnsiString. During the field test cycle of Tiburón and our own internal porting of the IDE code (which was accomplished in about 1.5 months, by 2-3 folks, with > 2 million LOC), it became clear that there was a need for easily encoding UTF16 character data as UTF8. For the astute among you, you probably already know about the RTL defined UTF8String which is really just an alias to AnsiString. The p...
Tags: CodeGear

Posted by on in Blogs
Brand New Day... Well, my access card worked.  I guess I still have a job :-). I just finished listening to a company (Embarcadero not Borland) wide conference call announcing to the whole company the closure of the Embarcadero+CodeGear deal. Wayne Williams, our new boss, made some very encouraging statements. Most notably was that just like ER/Studio, RapidSQL, and DBArtisan, Delphi/C++Builder are core Embarcadero product offerings. This means that these products are key to the business. Yes, there are ma...
Tags: CodeGear

Check out more tips and tricks in this development video: