Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2005, 11:06 AM
Registered User
 
Join Date: Nov 2005
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!


 
Old November 2nd, 2005, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
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
 
Old November 3rd, 2005, 05:54 AM
Registered User
 
Join Date: Nov 2005
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


 
Old November 8th, 2005, 04:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
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





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 07:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.