Tema: invoke
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/02/2009, 16:33
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 729
Antigüedad: 17 años, 8 meses
Puntos: 8
invoke

Hola:

En Visual C# Express 2008 me funciona muy bien el invoke, pero al intentar pasarlo a MonoDevelop 1 me da error que es este:

[Task:File=/home/metaconta/prueba_04/prueba_04/MainWindow.cs, Line=45, Column=22, Type=Error, Priority=Normal, Description=Type `MainWindow' does not contain a definition for `invoke' and no extension method `invoke' of type `MainWindow' could be found (are you missing a using directive or an assembly reference?)(CS1061)]

Sospecho que falta algún using o algo.

Código:
// MainWindow.cs created with MonoDevelop
// User: metaconta at 17:10*24/02/2009
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using Gtk;
using System.IO.Ports;
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Linq; 
using System.Text;

public partial class MainWindow: Gtk.Window
{	
	private SerialPort mySerial;
	// Utilizaremos un string  como Buffer de recepción.
	string Recibidos;
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		Build ();
		mySerial = new SerialPort("/dev/ttyS0", 9600, Parity.None, 8, StopBits.Two);
		if (!mySerial.IsOpen)
		{
			try
			{
				mySerial.Open();
			}
			catch (System.Exception ex)
			{
				label1.Visible = true;
				label1.Text = ex.ToString();
			}
		}
	// Ejecutar la función Recepcion por disparo de evento DataReived.
		mySerial.DataReceived += new SerialDataReceivedEventHandler(Recepcion);
	}
	
	// Al recibir los datos.
	private void Recepcion(object sender, SerialDataReceivedEventArgs e)
	{
		// Acumular los carácter recibidos a nuestro "buffer" (string).
		Recibidos += mySerial.ReadExisting();
		// Invocar o llamar el proceso de tramas.
		this.invoke(new EventHandler(Actualizar));
	}
	// Procesar los daros recibidos en el buffer y extraer tramas completas.
	private void Actualizar(object s, EventArgs e)
	{
		// Designar el valor de la trama textBox.
		//textview_visualizar_mensaje.Text = Recibidos;
		entry_visualizar_mensaje.Text = Recibidos;
	}
	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}

	protected virtual void OnButtonTClicked (object sender, System.EventArgs e)
	{
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x74; // ASCII letra t.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
	}

	protected virtual void OnButtonBClicked (object sender, System.EventArgs e)
	{
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x62; // ASCII letra b.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
	}

	protected virtual void OnButtonAClicked (object sender, System.EventArgs e)
	{
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x61; // ASCII letra a.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
	}

	protected virtual void OnButtonLClicked (object sender, System.EventArgs e)
	{
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x6C; // ASCII letra l.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
	}

	protected virtual void OnButtonEspacioClicked (object sender, System.EventArgs e)
	{
		byte[] mBuffer = new byte[1];
		mBuffer[0] = 0x20; // ASCII letra Espacio.
		mySerial.Write(mBuffer, 0, mBuffer.Length);
	}
}
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar