Hi all,
I am sorry if this question is duplicated, I did search and found nothing before posting this thread.
I do not know how to create a customize event listener. I do some example like:
Create interface InterfaceA
interface InterfaceA {
event1();
event2();
...
}
create a class that can trigger event, this class has a method to set listener.
class trigger
{
set onInterfaceA(InterfaceA client) { this.client=client}
.....
// code to trigger some where
{
if (client!=null) client.event1();
..............
taskA();
}
..............
{
if (client!=null) client.event2();
..............
taskB();
}
....
}
create class that can handle event
class handlerCustomerEvent() implement InterfaceA{
trigger mytrigger;
/////set its self as listener some where
......
{
mytrigger.onInterfaceA(this)
}
...
//An implement event1 & event1
public void event1() {
taskC();
}
public void event1() {
taskD();
}
}
Well, this way to reach the event is okie, but if taskA can not be performed until taskC is finish because all of event handle is function calling, not real trigger, that make me mad.
So, how to make a real trigger, in that, I trigger the event, and do the taskC without waiting for the completion of event handler method ?
Any help are appreciated.
Thank for reading this confused code
I am sorry if this question is duplicated, I did search and found nothing before posting this thread.
I do not know how to create a customize event listener. I do some example like:
Create interface InterfaceA
interface InterfaceA {
event1();
event2();
...
}
create a class that can trigger event, this class has a method to set listener.
class trigger
{
set onInterfaceA(InterfaceA client) { this.client=client}
.....
// code to trigger some where
{
if (client!=null) client.event1();
..............
taskA();
}
..............
{
if (client!=null) client.event2();
..............
taskB();
}
....
}
create class that can handle event
class handlerCustomerEvent() implement InterfaceA{
trigger mytrigger;
/////set its self as listener some where
......
{
mytrigger.onInterfaceA(this)
}
...
//An implement event1 & event1
public void event1() {
taskC();
}
public void event1() {
taskD();
}
}
Well, this way to reach the event is okie, but if taskA can not be performed until taskC is finish because all of event handle is function calling, not real trigger, that make me mad.
So, how to make a real trigger, in that, I trigger the event, and do the taskC without waiting for the completion of event handler method ?
Any help are appreciated.
Thank for reading this confused code

