void on_programar_clicked (object o,EventArgs args){ //Thread myThread = new Thread(new ThreadStart(Programar)); //myThread.Start(); GLib.Idle.Add (Programar); } void Programar(){ barra.Fraction=0; if (nombrefichero.Text==""){ Error("Tiene que especificar un archivo"); return; } try{ status.Push(0,"Abriendo Fichero:"); Fichero fichero=new Fichero(File.OpenText(nombrefichero.Text)); barra.Fraction=0.10; status.Push(0,"Abriendo Puerto"); SerialPort sp=new SerialPort(SerialPort.GetPortNames()[listapuertos.Active]); sp.Open(); barra.Fraction=0.20; status.Push(0,"Entrando Modo Monitor"); Gpbot gp=new Gpbot(sp); barra.Fraction=0.40; status.Push(0,"Borrando Flash"); gp.BorrarTodo(); barra.Fraction=0.60; status.Push(0,"Cargando Fichero"); gp.Programar(fichero); barra.Fraction=0.90; status.Push(0,"Ejecutando"); gp.Ejecutar(fichero); barra.Fraction=1; status.Push(0,"Ejecutado"); } catch (SerialPortException e){ } }