Hello,
i'm trying to create an application which exists of 2 forms:
a login form and a panel form.
Now the login form speaks for itself, when i press login i send a request to my server and the server returns some things..
I make use of a Form class which inits the form and a Client(Form login) class which do the networking.
Now when i insert a wrong pasword for example, i want it that it sets a text on the login panel to invalid password.
But the thing is that i get errors about cross threading when i set my text, EVEN if i use delegates to fix this.
But the problem is that i acces the text via an instance of the form class: this.loginForm. text = "invalid pass";
this code is in my Client class:
so how do i need to fix this???
Thanks in advance!
i'm trying to create an application which exists of 2 forms:
a login form and a panel form.
Now the login form speaks for itself, when i press login i send a request to my server and the server returns some things..
I make use of a Form class which inits the form and a Client(Form login) class which do the networking.
Now when i insert a wrong pasword for example, i want it that it sets a text on the login panel to invalid password.
But the thing is that i get errors about cross threading when i set my text, EVEN if i use delegates to fix this.
But the problem is that i acces the text via an instance of the form class: this.loginForm. text = "invalid pass";
this code is in my Client class:
Code:
private LoginForm login = <retrieved from constructor param>
delegate void updateLabelTextDelegate(string newText);
private void updateLabelText(string newText)
{
if (this.login.label4.InvokeRequired)
{
// this is worker thread
updateLabelTextDelegate del = new updateLabelTextDelegate(updateLabelText);
this.login.label4.Invoke(del, new object[] { newText });
}
else
{
// this is UI thread
this.login.label4.Text = newText;
}
}
Thanks in advance!
Comment