|
-
Jan 22nd, 2003, 04:51 AM
#1
Thread Starter
New Member
Help! How to share object between clients?
I have an object (Singleton) in ActiveX DLL and want to share it between several clients but new copy of it created for each client even if I use Standard Module. I try to experiment with Project options. But no success.
Who can help me with that problem???? (Maybe GOD )
-
Jan 23rd, 2003, 04:21 AM
#2
KING BODWAD XXI
do you mean you want to access details entered by another program in the activeX
-
Jan 23rd, 2003, 11:40 AM
#3
-
Jan 24th, 2003, 12:36 PM
#4
He might mean that he wants to share the instance of a class/dll started in 1 app with another app:
If so:
http://www.vbforums.com/showthread.p...=getobject+dll
-
Jan 27th, 2003, 12:54 PM
#5
Thread Starter
New Member
Thanks to Cander
Really thank's Cander. Beer to you
This is impressive.
-
Jan 29th, 2003, 07:13 AM
#6
Lively Member
i'm sorry guys,
but you'r totally wrong with this concept.
by using GetObject function u r absolutely NOT sharing object between clients because each client get is own copy (instance) of the class.
-
Jan 30th, 2003, 03:34 PM
#7
uhh no deja. GetObject does what it says. You are GETTING an instance and using it. CreateObject creates a new instance.
-
Jan 31st, 2003, 03:54 AM
#8
Lively Member
(sorry for my english)
let's have some order here.
there is a Commponent and ther is an Object.
Component is a DLL file that contain Class/es inside.
Object is an Instance of Class.
now, there is a different between ActiveX DLL that is "In-Process Component" and ActiveX EXE that is "Out-Of-Process Component".
ActiveX DLL always running in the client process (unless u put it in a DLL Surrogate, which is a separate process called DLLHOST.EXE. for instance, COM+ use it), ActiveX EXE always run in a separate process (Excel, Word etc. is a good example of ActiveX EXE).
GetObject function uses CoGetObject COM API function behind the scene, CoGetObject calls IMoniker::BindToObject method, and that method looks in the ROT (running object table) to find the specified server, if he find the object he bind the client to it (not precisely), if not he create new one.
but that's not precisely (as i mentioned), because it depend on the COM object type, if it is a in-proc component (ActiveX DLL) he always create a new instance because it is ALWAYS running in the client (of course that the Component (not the class) is only one instance in the system - that's the whole concept of DLL), so again u getting new instance of the Object, not the Component (COM is also much cleaver to separate Code and Data - so the code of the class maybe only have once).
in ActiveX EXE it is different, because it's running in a different process, so if u call GetObject u ALWAYS bind your variable to the running server.
the question (if i'm not wrong) was to be able to share data (or instances) between client. the ONLYway to do that is to use ActiveX EXE or using COM+ SPM (Shared Property Manager), or sending messages between two process (by using Pipes or something else), or even using DataBase or flat file.
i rest my case.
-
Feb 3rd, 2003, 07:45 AM
#9
Thread Starter
New Member
-
Feb 4th, 2003, 04:47 AM
#10
Lively Member
that code contain non trivial operations, and can cause some problems. that's also why visual basic do not supply this functions naturally.
u should read ome more stuff.
http://www.microsoft.com/msj/default...ctivex0895.htm
http://groups.google.com/groups?hl=i...TF-8%26hl%3Diw
http://msdn.microsoft.com/library/de...dn_objlife.asp
-
Feb 4th, 2003, 07:35 AM
#11
Thread Starter
New Member
So why i use this? Because i read so many papers and articles and all this information gave me equally NOTHING.
Why - because all authors was as so pessimistic as you!!!
You will never be SELECTED... because you not NEO.
Bye deja ...
-
Feb 4th, 2003, 09:10 AM
#12
Lively Member
first of all i'm not pessimistic.
what i'm trying to tell u is that there r different ways to implement COM Singleton, and better ways.
u know what? let's try something, add some code to your server:
Public Sub ShortOp()
End Sub
Public Sub LongOP()
Dim l As Long
Dim s As String
For l = 1 To 10000000
s = "xxx"
Next l
End Sub
now, add two command buttons to the client exe's and put that code:
Private Sub Command1_Click()
Server.ShortOp
MsgBox "short op over"
End Sub
Private Sub Command2_Click()
Server.LongOP
MsgBox "long op over"
End Sub
now, run these clients, press the button of LongOp at one of them, and then press the button ShortOp on the other client...
now what? u stuck, aren't you?
that exactly one of the problem i'm taking about.
if i would have to implement a singleton, i would do it with C++, not in VB, why? because ROT is obsolete and intend for backward compatibility. with COM Singleton your VB client need simply that code:
dim obj as MyServer.MyClass
set obj = new MyServer.MyClass
tha's all.
if u want to share information between clients, but still want each client to have it's own thread (so u won't get stcuk) use COM+ SPM or out-of-process COM object (ActiveX EXE).
-
Feb 6th, 2003, 04:58 AM
#13
Thread Starter
New Member
I agree with this but I need object only to share data.
If it were possible to share UDT i'll be doing it this way.
In short I was found what I need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|