473,499 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to invoke event

there are 2 class A and ALib
class A is general class
class ALib is library class
this class call each other...
A call Alib and then method of Alib call method of A....is it possible?
class is like below..
-------------------------------------------------------------------------
using ALib;
Class A
{
A();

funcA1()
{
// here!! use method of Class ALib
ALib alib = new ALib();
// When invoke funcALib of ALib i just wanna call fucnA2 on this
class(classA)
alib. funcALib();
}

funcA2(int a, int b)
{
// to do something
}

}
----------------------------------------------------------------------------
Class ALib
{
ALib();

funcALib()
{
// here!!!
// i just wanna call funcA2 of class A
// but how can i do this...
// should i use event or delegate??

A.funcA2(5,10); <--- i know it is impossible but how can i do this
??
}
}

Apr 19 '07 #1
2 1600
Yes, it is possible, but you have to pass the reference (using this) to
the ALib instance to call back into.

If these classes are in separate assemblies though, you are going to
have an issue, because you will not be able to set references to each other,
so you will have to pass either an interface implementation (which is
defined in an assembly outside of the two) or an object and use reflection
to make the calls on the object.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"somequestion" <so**********@gmail.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
there are 2 class A and ALib
class A is general class
class ALib is library class
this class call each other...
A call Alib and then method of Alib call method of A....is it possible?
class is like below..
-------------------------------------------------------------------------
using ALib;
Class A
{
A();

funcA1()
{
// here!! use method of Class ALib
ALib alib = new ALib();
// When invoke funcALib of ALib i just wanna call fucnA2 on this
class(classA)
alib. funcALib();
}

funcA2(int a, int b)
{
// to do something
}

}
----------------------------------------------------------------------------
Class ALib
{
ALib();

funcALib()
{
// here!!!
// i just wanna call funcA2 of class A
// but how can i do this...
// should i use event or delegate??

A.funcA2(5,10); <--- i know it is impossible but how can i do this
??
}
}

Apr 19 '07 #2
yes, these classes are in separate assemblies...so...i really don't know how
can i solve it..
could you give me some code..for explain...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com´ÔÀÌ ´ÙÀ½
¸Þ½ÃÁö¸¦ ÀÛ¼ºÇß½À´Ï´Ù. news:%2****************@TK2MSFTNGP06.phx.gbl...
Yes, it is possible, but you have to pass the reference (using this) to
the ALib instance to call back into.

If these classes are in separate assemblies though, you are going to
have an issue, because you will not be able to set references to each
other, so you will have to pass either an interface implementation (which
is defined in an assembly outside of the two) or an object and use
reflection to make the calls on the object.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"somequestion" <so**********@gmail.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
>there are 2 class A and ALib
class A is general class
class ALib is library class
this class call each other...
A call Alib and then method of Alib call method of A....is it possible?
class is like below..
-------------------------------------------------------------------------
using ALib;
Class A
{
A();

funcA1()
{
// here!! use method of Class ALib
ALib alib = new ALib();
// When invoke funcALib of ALib i just wanna call fucnA2 on this
class(classA)
alib. funcALib();
}

funcA2(int a, int b)
{
// to do something
}

}
----------------------------------------------------------------------------
Class ALib
{
ALib();

funcALib()
{
// here!!!
// i just wanna call funcA2 of class A
// but how can i do this...
// should i use event or delegate??

A.funcA2(5,10); <--- i know it is impossible but how can i do this
??
}
}

Apr 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1980
by: Charles Law | last post by:
I have a user control created on the main thread. Let's say, for arguments sake, that it has a single property that maintains a private variable. If I want to set that property from a worker...
21
6530
by: news.btinternnet.com | last post by:
I can do this in IE myLink.click(); //Invoking the handler as if the user had clicked on the link themselves. I need to be able to do the same in Netscape Navigator, can anyone help ?
1
4831
by: boxim | last post by:
hi all, I'm having a few problems whereby my application is hanging when using the Invoke method of a form's control. Basically, when a user clicks a button on the form, it calls a remote...
3
8844
by: David Logan | last post by:
I have an application using sockets, and it uses the asynchronous method for receiving (and others, but receiving is the basic problem.) In short, I want: class someClass: Form {...
3
1892
by: Alexander | last post by:
I have a dialog that loads a file from a web server, this is done in an own thread. On finish or failure the thread is supposed to raise an event notifying the dialog. If the WebRequest now raises...
2
2993
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
15
61948
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
7
10836
by: the_grove_man | last post by:
How do I invoke a "Right-Click" Programmtically? John
18
4581
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
2
4383
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.