Exception whilst updating data

May 27, 2009 at 8:06 PM

Using a scrollpanel with a number of controls on it, I register for postion updates from another thread providing positional information. The delegate gets called a number of times and then I get and exception :- Control.Invoke must be used to interact with controls created on a separate thread.
STACK:-
Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar)
  at System.Windows.Forms.Control.Invalidate(Rectangle rectangle)
  at Fluid.Controls.FluidHost.Fluid.Controls.IContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.FluidPanel.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.FluidPanel.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.NavigationPanel.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.TransitionPanel.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.ControlContainer.Invalidate(Rectangle bounds)
  at Fluid.Controls.FluidPanel.Invalidate(Rectangle bounds)
  at Fluid.Controls.FluidControl.Invalidate()
  at Fluid.Controls.FluidLabel.OnTextChanged()
  at Fluid.Controls.FluidLabel.set_Text(String value)
  at MyApp.ListBoxes.Navigate.BindData()
  at MyApp.ListBoxes.Navigate.mypositionsUpdated(Object sender, LocationChangedEventArgs args)
  at Store.GpsProcessor.gps_LocationChanged(Object sender, LocationChangedEventArgs args)
  at Store.GPS.WaitForGpsEvents()

void mypositionsUpdated(object sender, LocationChangedEventArgs args)
{
      position = args.Position;
      BindData();
}

I have attempted to isolate the postional updates from the grahics my adding a interface method like so :-
private void DoUpdate()
{
    if(this.InvokeRequired)
    {
        // we were called on a worker thread
        // marshal the call to the user interface thread
        this.Invoke(new UpdateStatusDelegate(DoUpdate));
        return;
    }

    // this code can only be reached
    // by the user interface thread
    BindData();
}

BUT this not compile as Invoke method in valid in this area.
Does anybody have any ideas on how I can update with the exceptions.


Thanks