Threading

  • Thread starter Thread starter aculfa
  • Start date Start date
A

aculfa

I'm about to finish a project but has a last problem. (may not be last
either) : )

It has 3 layer, Data-Business-GUI(includes main). Main is exe, others are
dll of course.

When "tablename" in Dataset changes in "Data Layer", I want to show the new
tablename on form (in a label) But because of layering "Data Layer" knows
nothing about my "Form".

How can I show tablenames on my form? (Without much performance effect)
 
I can't call

myForm.Invoke(myDelegate, new object[] {tablename});

since myForm is inaccessible.

Also because it is exe, I can't add it to References.

Thanks for your help,

Regards,
 
Hello

declare an event in you data class.

1- add these declarations to you data class.
delegate void TableNameChangedEventHandler(string newName);
public event TableNameChangedEventHandler TableNameChanged;
protected void OnTableNameChanged(string newName) {
if(TableNameChanged != null) {
TableNameChanged(newName);
}
}


2- In the method that triggers the event add this line when the event
occurs
OnTableChanged(newName);

3- In your form constructor add

myDataClassInstance.TableNameChanged += new
MyDataClass.TableNameChangedEventHandler(this.mymethod);

I hope this helps

Best regards,
Sherif


aculfa said:
I can't call

myForm.Invoke(myDelegate, new object[] {tablename});

since myForm is inaccessible.

Also because it is exe, I can't add it to References.

Thanks for your help,

Regards,

iletide þunu yazdý said:
I'm about to finish a project but has a last problem. (may not be last
either) : )

It has 3 layer, Data-Business-GUI(includes main). Main is exe, others are
dll of course.

When "tablename" in Dataset changes in "Data Layer", I want to show the new
tablename on form (in a label) But because of layering "Data Layer" knows
nothing about my "Form".

How can I show tablenames on my form? (Without much performance effect)
 
Solved the problem with CallBack functions.

Thanks for your help.


iletide þunu yazdý said:
Hello

declare an event in you data class.

1- add these declarations to you data class.
delegate void TableNameChangedEventHandler(string newName);
public event TableNameChangedEventHandler TableNameChanged;
protected void OnTableNameChanged(string newName) {
if(TableNameChanged != null) {
TableNameChanged(newName);
}
}


2- In the method that triggers the event add this line when the event
occurs
OnTableChanged(newName);

3- In your form constructor add

myDataClassInstance.TableNameChanged += new
MyDataClass.TableNameChangedEventHandler(this.mymethod);

I hope this helps

Best regards,
Sherif


aculfa said:
I can't call

myForm.Invoke(myDelegate, new object[] {tablename});

since myForm is inaccessible.

Also because it is exe, I can't add it to References.

Thanks for your help,

Regards,

iletide þunu yazdý said:
I'm about to finish a project but has a last problem. (may not be last
either) : )

It has 3 layer, Data-Business-GUI(includes main). Main is exe, others are
dll of course.

When "tablename" in Dataset changes in "Data Layer", I want to show
the
new
tablename on form (in a label) But because of layering "Data Layer" knows
nothing about my "Form".

How can I show tablenames on my form? (Without much performance effect)
 
Back
Top