Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 2nd, 2005, 10:06 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default communication between "parallel" objects

My first post here.it is more than likely to be an easy question to which i do not have an answer to.

I am working on an application with an mdi interface.
one scenario has the appli launching 2 child windows.
The logical & technical problem i am facing is making those 2 child windows interact between each other.

How can i make Child A tell Child B to do a certain task? How can i link them as they are independantely//parallely run?

without instanciating Child B in Child A.

Do i need to use pointers? get the collection of objects?
I have absolutely no idea as i am looking at possible answers

After having looked quite a bit around on the internet, i havnt found any answer, nor hint to my question which means that i am either
.asking the wrong question
.phrasing it wrongly
.asking such a fundamental/easy question that nobody has ever ran upon such problems

Thanks for your answers!


Reply With Quote
  #2 (permalink)  
Old November 2nd, 2005, 03:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

You didnít say much on what all approaches you have already tried. There are many things you can try here though. Like you can try setting up an event based communication amongst all the child forms.
Maintaining a collection of the children classes in the parent form, as you mentioned is another approach you can try.

And off course instead of asking ďif Iím asking it correctly", if you just explain it how you yourself would like such a problem to be explained to you, it will help people over here immensely in understanding your queries better.
For an instance at times a few pieces of code say a lot more than the tomes that people write explaining and documenting them.

Do write back, if thereís any thing else you wanna discuss.



Regards
Ankur Verma
Reply With Quote
  #3 (permalink)  
Old November 3rd, 2005, 04:54 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you are right, it definitely lacked details

so i have a main application
//Mdi Interface
public Class MainApp
{

//Event handler- launches the 2 child windows
private void eventhandler(object sender, System.EventArgs e){

//Instanciation of the 2 child windows
ClassA PFMdi = new ClassA();
ClassB PFMdi2 = new ClassB();

//windows display
PFMdi.Show();
PFMdi2.Show();

}
**********

Class A{

//Event handler 2 - launches 1 process in the Child A window +1 in
//the child B window
private void eventhandler(object sender, System.EventArgs e){

//Child A function - it works
this.ChildAfunction();
//Child B
???.ChildBfunction();
(how can i get the object 'Child B' from this level)
}

this problem reminds me of static classes, as you can call them anywhere in a program.

Class B {

ChildBfunction()
{
}

}


Thanks for your answers


Reply With Quote
  #4 (permalink)  
Old November 8th, 2005, 03:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

In place of ???.ChildBfunction(); either
A) fire an event to be handled in class B or
B) call the function though a delegate.

Case A: You will have to define an event and and an event handler in class B. Actually ChildBfunction can serve as a handler here.

Case B: Pass a delegate object (function reference) referering to a common function in the main class that will then call the relevent function in the relevent child class. You can pass the delegate object when u make objects of child window classes as a constructor parameter. U will have to write or change the constructor definition accordingly.

Regards
Ankur Verma
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Receiving data from parallel port using C#.net venkatvens Visual C++ 0 August 11th, 2008 05:44 AM
parallel communication in vc++ umang.cs Visual C++ 0 April 29th, 2006 10:23 AM
Visual C++ on parallel port yunarch Visual C++ 0 September 30th, 2005 07:40 AM
How Can I Read or Write to Parallel Port? qdata Visual C++ 3 January 31st, 2005 06:47 AM



All times are GMT -4. The time now is 09:44 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.