Articles
I frequently come across situations where I need a way to insert a key/value pair into a lookup table or update it if it already exists. So I figured I’d write a stored procedure that would do the following things for me:
♦ Accept the lookup key and value as input arguments and return the unique id of the new (or existing) key that was just inserted (or updated) as an output argument.
♦ Correctly deal with race conditions where two separate entities (processes, threads, etc…) are trying to insert or update the same lookup key/value pair and accomplish this without using a transaction.
♦ Accept the lookup key and value as input arguments and return the unique id of the new (or existing) key that was just inserted (or updated) as an output argument.
♦ Correctly deal with race conditions where two separate entities (processes, threads, etc…) are trying to insert or update the same lookup key/value pair and accomplish this without using a transaction.
With the advent of .NET and Windows Forms, a convenient new mechanism (Control.Invoke) was introduced to safely invoke methods on forms and controls from non-UI threads. But if you're like me, I'm sure you've wondered about the underlying implementation of this mechanism. For instance, how would one accomplish this from an unmanaged (non .NET) Windows application - without breaking the cardinal Windows rule of accessing controls only from the thread that created them?
