Cross Thread error on OnTileLoadComplete

May 11, 2010 at 10:08 AM

Hi - great control, save me an enormous amount of work and my project looks great

I recently downloaded the latest release (Form control), and there appears to be a change (maybe!)

I need to use the OnTileLoadComplete so that I can save the map as a bitmap - this worked fine, and through a bit of guess work used the parameter loaderID=3 which signified the (last?) level of the map had loaded - all was good

Now, the loaderID variable no longer appears valid, and whenever the OnTileLoadComplete is run (and say changes the value of a label), it comes up with a CrossThread error

 

any ideas?

May 11, 2010 at 10:38 AM

 

      // loader end loading tiles
      void MainMap_OnTileLoadComplete()
      {
         MethodInvoker m = delegate()
         {
            progressBar1.Visible = false;
            toolStripStatusLabelLoading.Visible = false;

            toolStripStatusLabelMemoryCache.Text = string.Format("MemoryCache: {0:0.00}MB of {1:0.00}MB", MainMap.Manager.MemoryCacheSize, MainMap.Manager.MemoryCacheCapacity);
         };
         try
         {
            BeginInvoke(m);
         }
         catch
         {
         }
      }
May 11, 2010 at 10:54 AM

Hi - thanks for the superfast response

I failed to tell you I was using VB, which is an oversite - my apologies for that

 

however using my (very) limited C>VB skills, I cannot get what you suggest to work - can you supply suitable code in VB.net, thanks

May 11, 2010 at 6:24 PM
Edited May 11, 2010 at 6:25 PM

 in .net language doesn't matter ;}

 

Private Sub MainMap_OnTileLoadComplete()
    Dim method As MethodInvoker = Function 
        Me.progressBar1.Visible = False
        Me.toolStripStatusLabelLoading.Visible = False
        Me.toolStripStatusLabelMemoryCache.Text = String.Format("MemoryCache: {0:0.00}MB of {1:0.00}MB", Me.MainMap.Manager.MemoryCacheSize, Me.MainMap.Manager.MemoryCacheCapacity)
    End Function
    Try 
        MyBase.BeginInvoke(method)
    Catch obj1 As Object
    End Try
End Sub
May 25, 2010 at 8:43 PM

Cheers - just the job - excellent work as always