This project has moved. For the latest updates, please go here.

Using ShowProgressUpdate with TileAsyncLayer - Cross thread violation

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Nov 29, 2013 at 2:52 PM
Hi all,
I've tried to show mapbox - progress bar with tile async layer and when it's trying to update progress bar (ui-element) from tile-thread it throws InvalidOperationException with following details:
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
So i've checked the source code of MapBox.cs within SharpMap.UI. In the UpdateImage function tries to set both visible/enable properties of progress bar. This is why it's throwing exception, so i've changed these two lines:
_progressBar.Visible = true;
_progressBar.Enabled = true;
_progressBar.Invoke((MethodInvoker)(() => _progressBar.Visible = true));
_progressBar.Invoke((MethodInvoker)(() => _progressBar.Enabled = true));
Nov 29, 2013 at 6:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Marked as answer by ahmetkakici on 11/29/2013 at 12:00 PM