[Gtk-sharp-list] Application.Invoke and threads: strange behavior

amartinez at atc.ugr.es amartinez at atc.ugr.es
Tue Oct 18 12:16:03 EDT 2005


> So could this be a 2.0 usecase for an Application.Invoke that takes a
> defined parameter? :)
>
> --Todd

Please commit the patch. I vote for it.

:-)

Meanwhile I have fixed my problem changing my ThreadFunc as pasted.
I'm sure this isn't the most "best practice" to do it, do you know
another way (using Application.Invoke)?

//Following the monodoc documentation tmp2 should be "The sender to pass
to //the event handler" ... but for now it solves my problem

public void ThreadFunc()
{
  while ((tmp = p.StandardOutput.ReadLine()) != null)
  {
    string tmp2 = tmp;
    Console.WriteLine (tmp);
    Application.Invoke (tmp2, null, delegate
	{
          buff.Text += System.Environment.NewLine + tmp2;
	}
    );
  }
}

Regards,

--
Antonio Martínez Alvarez



More information about the Gtk-sharp-list mailing list