[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sharing data between two instances of the same program

Posted on 2009-05-02
13
Medium Priority
?
740 Views
Last Modified: 2012-08-14
I have a program that display forms with different data.  All the data is stored in a multiple dimension array.  I run two instances of the program and display a different form in each.  I can copy data from one form to another (different program instances), but I wish to share the data in the multiple dimension array.  Please share some simple code to do this.
Thanks, Harold


 
<Serializable()> _ 
 Public Class ObjData
      Public Image As Image
      Public Text As String
      Public Path As String
   End Class
Public GoData(3, 7, 31) As ObjData

Open in new window

0
Comment
Question by:hlominac
  • 7
  • 2
  • 2
  • +2
13 Comments
 
LVL 9

Expert Comment

by:CyberLex
ID: 24286182
Greetings

I think this is what you are looking for, doesn't look too complicated :=)

http://www.thescarms.com/vbasic/PassString.aspx


cheers,
Alex
0
 

Author Comment

by:hlominac
ID: 24286208
I found that before, but I didn't try it out.  I will get back with you later after I have worked with it a bit.  I'm working outside just now.
Harold
0
 

Author Comment

by:hlominac
ID: 24286321
I was looking for something less complicated.  
Firstly, Dave wrote the code in Visual Basic, I am using VB.NET.  
Secondly he uses API calls, which I wish to avoid.
I was hoping that I could use something that could share my objData.GoData (see snippet.)
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:hlominac
ID: 24286328
Oh yes.  He only was sending striings and numbers.  I am sending objects.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24286582
Remoting is what you want:
http://msdn.microsoft.com/en-us/library/kwdt6w2k(VS.71).aspx
(yes...you can communicate locally between two apps)

0
 
LVL 1

Expert Comment

by:ltgbau
ID: 24286833
why don't you store data in file, registry or something like that?
that's simple and effectively solution :D
0
 

Author Comment

by:hlominac
ID: 24287090
ltgbau: That is what I am doing just now with the pieces I am saving.  I pass the data through the clipboard.  However the data is stored internally, and when I save to disk I am not saving all the data.  I havent used SyncLock yet.  I am trying to get around it another way.  I am familiar with using the registry, but I never have tried to save a whole array such as this.
What I need is a common source that I can read and write to from either program.  Then I can save it to a hard drive when I finish.  If I use a temporary file like the registry, it is the same as reading and writing to the hard drive.
Idle_Mind: Is remoting the same as the above?  What I am doing is cutting information from one program that changes the data, and then pasting the data in the other program.  That changes the data too, so the data is not synchronized.  That is why I want a common database. I write my on databases, so I have tried to avoid huge databases stored on a server.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1500 total points
ID: 24287500
Using remoting you can pass the data BOTH ways...allowing it to be "synchronized" when one app changes the data...
0
 
LVL 20

Expert Comment

by:thehagman
ID: 24287568
Don't they have memory-mapped files in .NET?
These work like an extra swap file, are automatically shared between applications, swapped into memory when needed and saved to disk when done (esp. when apps close)
0
 
LVL 1

Expert Comment

by:ltgbau
ID: 24288348
In C++ i've use this to use common data between two DLL instances.
I think this is what you want for the problem
#pragma data_seg("SHARED")
int __x = 0;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")

Open in new window

0
 

Author Comment

by:hlominac
ID: 24291637
I retired as an engineer in1991, and I began programming VB.NET soon after it was released.  Some of your recommendations are beyond my knowledge, so I rely on you experts to tutor me as continue to learn. Just now I am leaning toward remoting.   I downloaded VisualBasic.msi and have been looking at Advanced - Remoting - How-To TCP Remoting.  I was able to get the example to run, but to convert the example for my application may take some time.  Can you recommend any more sources as a tutorial?
0
 

Author Comment

by:hlominac
ID: 24301139
Well I learned a lot, so now it is time to pay the piper.  I thank each of you for your comments, because I pursued them to the depth of my understanding and evaluated them according tom y needs.  I also thank you for responding quickly over the weekend.  Harold.
0
 

Author Closing Comment

by:hlominac
ID: 31577166
The solution was not as easy as I had hoped, but it pointed me in the right direction.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question