Jump to content
BlitzMX

[Resolvido] Chamar componente de dentro de uma thread.

Recommended Posts

BlitzMX

RESOLVIDO

Boa tarde

Tenho um botão... Quando clico dispara uma thread que corre uma class.

Dentro da class os controlos estão a dar erro:

Botão:

private void btnIniciar_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(ThreadProc));
t.Start();
}

Class:

private static void ThreadProc()
 {
	 int rowi;
	 if (lblEstado.Text != ("Ficheiro Incorrecto"))			
	 {
		 for (rowi = 0; rowi < dataGridView1.Rows.Count - 1; rowi++)
		 {

			 if (Convert.ToString(dataGridView1.Rows[rowi].Cells[0].Value) != "")
			 {
				 webBrowser1.Navigate("URL Privado Confidencial" + Convert.ToString(dataGridView1.Rows[rowi].Cells[0].Value));
				 while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
				 {
					 Application.DoEvents();
				 }
			 }
			 else
			 {
				 break;
			 }
		 }

	 }		

 }

Obtenho um erro sublinhado a vermelho em lblEstado, dataGridView1 e webBrowser1, ou seja, os componenets do form que estou a chamar.

ERRO: An object reference is required for non-static field, method or property.

Sou novato e não percebo nada disto.

Até posso estar a dizer disparate.

Abraço e obrigado

Edited by BlitzMX

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.