Hi all, I have a problem (again and again...) with my mono application. After having created a GUI with gtk#, and configured a serial port connection, now I have to mix these 2 applications! In fact I would like to set the text of a label to indicate the state of the serial port. I created a thread which do that but the label aren't update properly. I read this page : http://www.mono-project.com/Responsive_Applications but my english level isn't very high. So I understand that: => the operations cross thread are not allowed (a thread can't modify the object's properties which another Thread has created). => I must use delegate.
That why I do that : (but it doesn't work!!!) t = new System.Threading.Thread(new ThreadStart(thread_Process)); private void readData_Clik(object sender, System.EventArgs e) { t.Start(); } private void thread_Process() { OpenSerialPort(); Gtk.Application.Invoke(delegate { myLabel.Text = "The serial port is open"; }); string[] rxdata = new string[]; rxdata = ReadData(); Gtk.Application.Invoke(delegate { myLabel.Text = "The data have been read"; labelVal1.Text = rxdata[0]; labelVal2.Text = rxdata[1]; }); CloseSerialPort(); Gtk.Application.Invoke(delegate { myLabel.Text = "The serial port is close"; }); } The labels are not update each time! Moreover the code execution time is slower than if I do that not in a thread... I don't understand. Thanks in advance. -- David ARNAUD-GODDET
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list