-
November 27th, 2008, 06:47 AM
#1
Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
When using MS C++, I can share data between two instances of an application by defining it within a shared data segment viz:
#pragma data_seg(".sdata")
int sharedint = 0;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.sdata,rws")
Is there a way of doing this in C#?
Thanks
M.
-
November 27th, 2008, 08:21 AM
#2
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
>> Is there a way of doing this in C#?
Yeah, however you do shared memory in .NET - which I'm not familiar with. I just want to point the dangers of shared sections in C++.
http://blogs.msdn.com/oldnewthing/ar...04/208003.aspx
gg
-
November 27th, 2008, 09:18 AM
#3
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
I am aware of this, but still, any ideas how to do what I want?
-
November 28th, 2008, 06:14 PM
#4
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
You can create the shared section (or the more secure file mapping) in a dll and pinvoke to it in the .net application.
Another approach is to have the application host a WCF web service to perform the data transfer.
With this approach, the first instance of the application would host the WCF service and subsequent instances would simply connect to the service.
-
December 4th, 2008, 08:05 AM
#5
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
Originally Posted by Arjay
Another approach is to have the application host a WCF web service to perform the data transfer.
Isn't it too heavy solution? What about remoting or named pipes? I think that named pipes is designed exactly for similar scenarios.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
December 4th, 2008, 01:55 PM
#6
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
Originally Posted by boudino
Isn't it too heavy solution?
I don't think so. Unlike a .Net 2.0 Web service, it's quite simple to host a WCF service inside a .Net application. See http://msdn.microsoft.com/en-us/library/ms731758.aspx for more info.
-
December 5th, 2008, 03:50 AM
#7
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
I know, but event in this case, the whole WCF machinery with all dispatchers, channels and all the infrastructure is in the play. It will definitely work, but I still think that if the communication is in-process or in-machime (as I understand the original question), the overhead is too big.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
December 5th, 2008, 03:23 PM
#8
Re: Equivalent to #pragma dataseg, #pragma comment - need to create shared seciton
Originally Posted by boudino
It will definitely work, but I still think that if the communication is in-process or in-machime (as I understand the original question), the overhead is too big.
Respectfully, please define 'too big'.
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
|