MTS Programming

MTS Programming

Question:
Should I make a call to GetObjectContext() in every function in my DLL?

Obviously, you are going to do that in your “main” methods, but does calling GetObjectContext() in every function (main and helper functions) make your code more efficient?

In the following example I’ve called GetObjectContext() in each function. Is that overkill or quality coding practice?

Function Sum(nNumber1, nNumber2) as Integer '--- this is the main function a client would call GetObjectContext() '--- now call helper function to do the work nAnswer = TotalThem(nNumber1, nNumber2) Sum = nAnswer End Function Function TotalThem(nNumber1, nNumber2) as Integer GetObjectContext() TotalThem = nNumber1 + nNumber2 End Function 

Answer:
MTS automatically creates the ObjectContext for each object when you instantiate an object under MTS. You call GetObjectContext from a method when you need to perform certain actions. The GetObjectContext method returns a reference to the ObjectContext object. You can use this object to:

  • Declare that the object’s work is complete. Prevent a transaction from being committed, either temporarily or permanently.
  • Instantiate other MTS objects and include their work within the scope of the current object’s transaction.
  • Find out if a caller is in a particular role.
  • Find out if security is enabled.
  • Find out if the object is executing within a transaction.
  • Retrieve Microsoft Internet Information Server (IIS) built-in objects.

So, no, you do not have to call the GetObjectContext method as you are doing in each method. You only need to call it when you need to do one of the above actions. Also, in Windows 2000, call the ObjectContext.CreateInstance in order to instantiate other MTS Objects so they live in the same transaction that has been removed.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes