Codeunit instances

bijaljambusaria
Member Posts: 46
Dear All,
Can you please clarify what is the meaning of "codeunit instance"? What is single instance and multi instance codeunit? It would be great if the guidelines are supported with examples. :!:
Thanx
Can you please clarify what is the meaning of "codeunit instance"? What is single instance and multi instance codeunit? It would be great if the guidelines are supported with examples. :!:
Thanx
0
Comments
-
Are you sure that you are asking in correct Forum? It is about NAV or MS CRM?0
-
I am sorry. I know I have made mistake of posting the topic in wrong forum but I dont know how to move this topic to Navision General...0
-
[Topic moved from Dynamics CRM (formerly CRM) to Navision forum]0
-
Instance - it is like Object and Class.
If I have two variables of type Codeunit 80 (for example...)SalesPost.Blablabla; SalesPost2.Blablabla;
I have two instances of the codeunit 80. If the function Blablabla works with global variables in the codeunit, the change through variable SalesPost will not be visible in SalesPost2 (there are two objects in memory, two separate memory area for each INSTANCE).
But if I set the property SingleInstance = Yes, both variables will work with same instance of the codeunit, all global variables in the codeunit will be shared through all variables of type Codeunit 80.
"Multi instance":
SalesPost --- CU80
SalesPost2 --- CU80
"Single instance":
SalesPost --- CU80
SalesPost2 --/0 -
OK let's put it in some other way: probably the only time you'd use a singleinstance CU is whenever you write some interface routine that runs continuously and waits for data to appear for it to pick up on the disk or in an MSMQ queue etc.0
-
Or because you want to optimize setup table readings (read once per client run), or you need to pass parameters between objects - in cases when you need "shared" memory space which can be used for communication... 8)0
-
Thanx... ! =D>0
-
Hi All
Codeunit has two type of instances. i don't know the Practical use of codeunit single instance and multiple instance. If anyone explain with examples, it will be very understandable to me...... O:)Dream is not the thing, what you see in the sleep. Dream is the thing, which does not let you sleep.0 -
and do you understand the theoretical part of this?0
-
This is the problem, if somebody does not know the basic OOP theory it becomes rather difficult to explain. This is a NAV forum not an OOP one.
A single instance codeunit is basically one that can only exist as a single object. Once the object is created, it stays in memory until it is killed by closing of the company. Any new creations of this codeunit will not actually create a new object, but rather refer directly to the one that currently exists. All of its internal global variables and their states are kept over all references to the object.
A multiple instance codeunit is exactly what it says on the tin. Every new creation of the codeunit creates a new object that has its own set of variables in their own state. It is also deleted when it goes out of scope.0 -
Thanx \:D/Dream is not the thing, what you see in the sleep. Dream is the thing, which does not let you sleep.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions