I have a program I wrote on the ChipworkX that receives events from my GPS.
The problem is that I cannot set WPF UIElement within this event handler, presumably because the event is outside the WPF window’s thread.
Any ideas on how to deal with this?
GPS = new MicroGPS("COM1", 9600);
GPS.GPSUpdate +=new GPSUpdateDelegate(GPS_GPSUpdate);
InitLabel(ref Fix, "Waiting for GPS data");
InitLabel(ref Lat, "Lat: --");
InitLabel(ref Lon, "Lon: --");
this.Visibility = Visibility.Visible;
}
void GPS_GPSUpdate(RMCOutput rmc)
{
switch (rmc.Fix)
{
case FixType.Active:
Fix.TextContent = "Fix Active";
break;
case FixType.Unknown:
case FixType.Void:
Fix.TextContent = "No Fix";
break;
}
Lat.TextContent = "Lat: " + rmc.Coords.Latitude.ToString();
Lat.TextContent = "Lon: " + rmc.Coords.Longitude.ToString();
}
[quote] #### Exception System.InvalidOperationException - 0x00000000 (3) ####
#### Message:
#### Microsoft.SPOT.Dispatcher::VerifyAccess [IP: 000c] ####
#### Microsoft.SPOT.DispatcherObject::VerifyAccess [IP: 000d] ####
#### Microsoft.SPOT.Presentation.Controls.Text::set_TextContent [IP: 0004] ####
#### Waypointer.Presentation.MainWindow::GPS_GPSUpdate [IP: 0029] ####
#### ChrisSeto.GeoInfoSystems.MicroGPS.MicroGPS::GPSSerialHandle_DataReceived [IP: 018a] ####
#### System.IO.Ports.SerialPort::DataEventHandler [IP: 0012] ####[/quote]