Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2006

Tip: Looking for answers? Try searching our database.

Singleton per DLL instance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Herby - 21 Apr 2006 14:20 GMT
I am going to develop a multi-threaded application that creates many
instances of a calculator object.  Consequently the DLL housing the
Calculator is to be thread safe.

Within the DLL i want some global singleton objects - these then become
accessible from all sub-objects comprising the calculator DLL. But i
only want these singletons to be accessible from anywhere within the
current calculator instance not across all calculators.

Its usual to make singletons static.  But this would then make it
accessible across all concurrent instances, thus compromising my thread
safety.

How can i have a DLL instance singleton ?
Herby - 21 Apr 2006 14:59 GMT
I tried just declaring a global instance and now get the following
error

error C3145: 'flowControlStack' : global or static variable may not
have managed type FlowControlStack
Marcus Heege - 21 Apr 2006 16:40 GMT
In theory, you could also use the code below, ....

#include <msclr/gcroot.h>

msclr::gcroot<FlowControlStack> g_fcs;

... but I would prefer a static variable of a managed class instead.

Marcus

>I tried just declaring a global instance and now get the following
> error
>
> error C3145: 'flowControlStack' : global or static variable may not
> have managed type FlowControlStack

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.